3 ms·
I guess that works, but it's a pretty big departure from the expected API of a normal namedtuple, or any other object-with-constructor, for that matter.
by mikepurvis 9y ago
I guess that works, but it's a pretty big departure from the expected API of a normal namedtuple, or any other object-with-constructor, for that matter.
- sevensor 9y agoIf you really want it to look more traditional, you could do: NT.new = lambda **kwargs: NT(42, 'foo')._replace(**kwargs) Now you can make NT objects like so: nt1 = NT.new() nt2 = NT.new(b='bar') You can call it something else if calling it "new" makes you feel weird. (I'd call it something else, but naming things is hard.)