namedtuple in Python 2.5

I am aware that the namedtuple class exists from 2.6 onwards. Is there a way of implementing similar functionality in Python 2.5 so normal tuples can be made to achieve this?

Student = namedtuple('Student', 'name serial')

Answers


There is a recipe to implement named tuples in Python 2.4 and later. You can compare this to the actual implementation of named tuples in, say, Python 2.7 here.


The actual source of the namedtuple in Python is this recipe here: Named Tuples.

The resulting recipe has been well received, so it was proposed and accepted for inclusion in the collections module for Py2.6.


Need Your Help

Animate(Blink) ListView from Custom Rows

android android-layout listview android-listview android-animation

I am trying to blink listView Custom rows although I am looking for Fade in Fade out animation for listview rows, but in below code I am just changing image after a second and having problem in set...

C/C++ Unicode characters encoding sizes and default formats

c++ visual-studio-2012 unicode character-encoding multibyte

I just realized that (thanks to my university course) many of the things I thought I knew about unicode were wrong. Thus I started reading and fixing my knowledges and the following doubts immediat...