On 16.01.2014 16:57, Guido van Rossum wrote:
> Because somehow you can't have a slot named __doc__ *and* a docstring
> in the class. Try it. (I tried to work around this but didn't get very
> far.)
That's true for all class attributes. You can't have a slot and a class
attribute at the same time. After all the __doc__ string is stored in a
class attribute, too.
>>> class Example:
... __slots__ = ("egg",)
... # This doesn't work
... egg = None
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: 'egg' in __slots__ conflicts with class variable
>>> class Example:
... """doc"""
... __slots__ = ("__doc__",)
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: '__doc__' in __slots__ conflicts with class variable
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com