By Denilson Sá Maia


2010-06-03 23:50:16 8 Comments

Reading the changes in Python 3.1, I found something... unexpected:

The sys.version_info tuple is now a named tuple:

I never heard about named tuples before, and I thought elements could either be indexed by numbers (like in tuples and lists) or by keys (like in dicts). I never expected they could be indexed both ways.

Thus, my questions are:

  • What are named tuples?
  • How to use them?
  • Why/when should I use named tuples instead of normal tuples?
  • Why/when should I use normal tuples instead of named tuples?
  • Is there any kind of "named list" (a mutable version of the named tuple)?

Related Questions

Sponsored Content

22 Answered Questions

[SOLVED] What are metaclasses in Python?

62 Answered Questions

[SOLVED] How to call an external command?

42 Answered Questions

[SOLVED] How to get the current time in Python

  • 2009-01-06 04:54:23
  • user46646
  • 3416215 View
  • 3026 Score
  • 42 Answer
  • Tags:   python datetime time

33 Answered Questions

[SOLVED] What does if __name__ == "__main__": do?

44 Answered Questions

19 Answered Questions

[SOLVED] Convert bytes to a string

31 Answered Questions

[SOLVED] "Least Astonishment" and the Mutable Default Argument

42 Answered Questions

[SOLVED] What does the "yield" keyword do?

10 Answered Questions

[SOLVED] Does Python have a string 'contains' substring method?

26 Answered Questions

[SOLVED] Does Python have a ternary conditional operator?

Sponsored Content