> But it would silently do nothing if there was no class decorator to look
> at it.
>
This doesn't seem like such a big deal to me. It would simply be the way
slots works.
However if we did `__slots__ = "__auto__"` then we might finagle it so that
> the initializers could be preserved:
>
> class C:
> __slots__ = "__auto__" # or MRAB's suggested __slots__ = ...
> x: float = 0.0
> y: float = 0.0
>
I do like this idea a lot.
Saving, or preserving, the initialized values somewhere is mainly what I
was driving at with the so called __slots_conflicts__ idea. Perhaps instead
the slots descriptor object could store the value? Something like:
class C:
__slots__ = ...
x: float = 0.0
y: float = 0.0
assert C.x.__value__ == 0.0
assert C.y.__value__ == 0.0
If that becomes the way this is solved, should slots be made to also accept
a dict to create starting values?
class C:
__slots__ = dict(x = 0.0, y = 0.0)
assert C.x.__value__ == 0.0
assert C.y.__value__ == 0.0
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/ONI45K3J4WMIGBXJVOTXCCCO3N4QDYNL/
Code of Conduct: http://python.org/psf/codeofconduct/