[Python-Dev] Py2.6 ideas

Raymond Hettinger python at rcn.com
Tue Feb 20 08:58:58 CET 2007


More thoughts on named tuples after trying-out all of Michele's suggestions:

* The lowercase 'namedtuple' seemed right only because it's a function, but
as a factory function, it is somewhat class-like.  In use, 'NamedTuple' more
closely matches my mental picture of what is happening and distinguishes
what it does from the other two entries in collections, 'deque' and 
'defaultdict'
which are used to create instances instead of new types.

* I remembered why the __repr__ function had a 'show' argument.  I've
changed the name now to make it more clear and added a docstring.
The idea was the some use cases require that the repr exactly match
the default style for tuples and the optional argument allowed for that
possiblity with almost no performance hit.

The updated recipe is at 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/500261


Raymond


More information about the Python-Dev mailing list