Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,275 members, 7,780,623 topics. Date: Thursday, 28 March 2024 at 05:51 PM

Named Tuple In Python - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Named Tuple In Python (2330 Views)

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)

(1) (Reply) (Go Down)

Named Tuple In Python by PrinceNN(m): 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(m): 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
Re: Named Tuple In Python by PrinceNN(m): 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.
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.

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-python
yea, 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(m): 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...
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...

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 grin
am also new to the python scene too...but its been a blast

(1) (Reply)

Your Career Is Your Future,get Best Web Development Training With Yemlat / Regular Programming Challenges With The Odd Money To Win / Anyone Currently Focusing On Data Structures And Algorithms?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.