Metaclass and __slots__
Peter Otten
__peter__ at web.de
Thu Nov 6 03:09:56 EST 2003
anabell at sh163.net wrote:
> Do I need to define my own metaclass in order to use __slots__?
Some things ar better tried than asked :-)
>>> class S(object):
... __slots__ = "slots are bad".split()
...
>>> s = S()
>>> s.bad = "as you can get"
>>> s.good = "to know"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'S' object has no attribute 'good'
>>>
Peter
More information about the Python-list
mailing list