[Python-Dev] Rationale for different signatures of tuple.new and namedtuple.new (original) (raw)
Hrvoje Niksic hrvoje.niksic at avl.com
Mon Feb 18 16:02:10 CET 2013
- Previous message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Next message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 02/18/2013 03:32 PM, John Reid wrote:
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?
Sharing the constructor signature with tuple would break the common case of:
namedtuple('B', 'x y z')(1, 2, 3)
- Previous message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Next message: [Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]