[Python-ideas] namedtuple baseclass

Chris Angelico rosuav at gmail.com
Sun Jan 12 12:46:51 CET 2014


On Sun, Jan 12, 2014 at 10:43 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> It's a tuple. It already uses __getitem__ to return items indexed by
> position. Adding magic so that obj["fields"] is an alias for
> obj._fields is, well, horrible.

It's only an alias in the simple version that I did there. If it were
to be used as a means of avoiding the _fields reserved name, it
wouldn't be an alias. But yes, it is somewhat magical. I was hunting
for an out-of-band way to get that sort of information.

ChrisA


More information about the Python-ideas mailing list