[Python-Dev] Rationale for different signatures of tuple.new and namedtuple.new (original) (raw)
John Reid j.reid at mail.cryst.bbk.ac.uk
Mon Feb 18 15:32:26 CET 2013
- Previous message: [Python-Dev] Fwd: PEP 426 is now the draft spec fordistribution metadata 2.0
- Next message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I can do
tuple([1,2,3])
but not:
from collections import namedtuple namedtuple('B', 'x y z')([1,2,3])
I get a TypeError: new() takes exactly 4 arguments (2 given) However I can do:
namedtuple('B', 'x y z')._make([1,2,3])
So namedtuple's _make classmethod looks a lot like tuple's new(). What's the rationale for this? Wouldn't it be better to share the same signature for new?
IPython's serialization code depends on a tuple's new() having the signature that tuple has and therefore does not work with namedtuples. See discussion here: http://article.gmane.org/gmane.comp.python.general/726849
Thanks, John.
- Previous message: [Python-Dev] Fwd: PEP 426 is now the draft spec fordistribution metadata 2.0
- Next message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]