>> The `__dict__` is needed to store the field names -- did you add `__dict__` to the
>> `__slots__`?
Nope — though the error indicated that I couldn’t add anything to __slots__ when subclassing tuple. But I may have misunderstood the error.
Also, frankly, I’m completely confused by __slots__ : looking at the namedtuple implementation, it sets slots to an empty tuple. But it does have instance attributes without a __dict__.
> Maybe I'm being an ignoramus but: how would it be possible to even use slots? Slots
> are descriptors living in the class namespace. You don't know ahead of time what the
> member names are, so you can't use slots, right?
The idea there is that you’d store the field names in a slot, and dynamically return the values in __getattr__.
In that case, frozen dict would be nice :-)
Anyway — good idea? I don’t know, ‘cause I did get it to work :-)
-CHB
You can use them, just make sure one of the slots is `__dict__`.
Of course, by adding `__dict__` you lose most (all?) of the advantages of using `__slots__` in the first place.
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QM7MIHKP2GSBN6TYMPDIFKGHGC7KEH6E/
Code of Conduct: http://python.org/psf/codeofconduct/