Named Tuple In Python - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Named Tuple In Python (2429 Views)
| Named Tuple In Python by PrinceNN(op): 5:53pm On May 30, 2012 |
Came accross namedtuples in python documentation, and it seems to be a very important feature. it helps to access fields by name instead of just index i think. my question is; How relevant is this feature? and how often do u use it in your code? |
| Re: Named Tuple In Python by Seun(mod): 2:01am On May 31, 2012 |
I don't use it as often as I thought I'd use it when it was first released. I think that's because of the restrictions of the feature, namely: 1) You must know all the fields of the namedtuples before creating the type. Advantage: dict. 2) You can't update the elements of a namedtuple. Advantage: class. |
| Re: Named Tuple In Python by ektbear: 4:01am On May 31, 2012 |
This seems pretty relevant: http://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python |
| Re: Named Tuple In Python by PrinceNN(op): 7:23am On May 31, 2012 |
Seun: I don't use it as often as I thought I'd use it when it was first released.thats exactly what i wanted to find out, i taught it would be a very important and neccessary feature to always implement in writing codes. thanks for your view anyways ekt_bear: This seems pretty relevant: http://stackoverflow.com/questions/2970608/what-are-named-tuples-in-pythonyea, came across this...just wanted to know how often its being used by the programmers themselves |
| Re: Named Tuple In Python by kodebin(m): 2:09pm On May 31, 2012 |
Well, They aint Totally useless per say... Tuples can be used when Dealing with for Eg months, Dates in a year which is always Constant... The Disadvantage as Mr Seun pointed out is that the Values aint Mutable.. Lists and Dictionaries are used more often due to Their mutable nature... Well just started Learning python 2days ago.. My Humble 2cents... |
| Re: Named Tuple In Python by PrinceNN(op): 3:53pm On May 31, 2012 |
kodebin: Well, They aint Totally useless per say... Tuples can be used when Dealing with for Eg months, Dates in a year which is always Constant...nop...was referring to namedtuples not normal [url=docs.python.org/release/1.5.1p1/tut/tuples.html]tuples[/url]...but ur 2cents has been collected tho ![]() am also new to the python scene too...but its been a blast |
How To Code Your Own Personal Assistant In Python • Quadratic Equation Solving App I Developed In Python • Official Thread For Experts And Begineers In Python • 2 • 3 • 4
Fingerprint Matching Application • A Universal Sdk For Finger Print Scanner • I Want To Become A Hacker And I Need A Good Source, Any Help?
