Can __iter__ be used as a classmethod?
Alex Martelli
aleax at aleax.it
Thu Mar 13 02:54:32 EST 2003
Aahz wrote:
...
>> """Subclasses of Frozen are frozen, i.e. it is impossible to add
>> new attributes to them and their instances, except via inheritance"""
...
> Why the heck didn't you use __slots__?!?!?!
Just using __slots__ (without a custom metaclass) would NOT "freeze" any
subclass: just by subclassing, you'd get instances to which attributes
could freely be added.
A custom metaclass might well be a more suitable approach, of course,
and it could, in particular. use __slots__ to optimize things.
Alex
More information about the Python-list
mailing list