On 18/02/13 14:12, Oscar Benjamin wrote: > On 18 February 2013 13:51, John Reid <johnbaronr...@gmail.com> wrote: >> On 18/02/13 12:03, Oscar Benjamin wrote: >>> On 18 February 2013 11:47, John Reid <johnbaronr...@gmail.com> wrote: >>>> Hi, >>>> >>>> I was hoping namedtuples could be used as replacements for tuples in all >>>> instances. >>> namedtuples are not really intended to serves as tuples anywhere. They >>> are intended to provide lightweight, immutable, hashable objects with >>> *named* (rather than numbered) values. >> If they are not supposed to be tuples then calling them namedtuples and >> inheriting from tuple seems a little odd. > You can use namedtuple instances in places that expect tuples. > Inheriting from tuples enables them to be all the things I said: > lightweight, immutable and hashable. The type object itself has a > different interface for the constructor, though. > > Then I can't use them in every place I use tuples. For example IPython relies upon the type's interface for the constructor as part of a serialization mechanism.
I wonder why they have a different interface. It seems to restrict their usability. No doubt there were other factors involved in the design of the interface. John. -- http://mail.python.org/mailman/listinfo/python-list