> I was thinking it's currently an error. And you chose a name > (__slot_conflics__) suggesting that there still was a problem. But yeah, > maybe other than that it's no big deal. >
It's a good point; the name does seem to say "here's a problem that needs to be solved". Your comment makes me think all the more that attaching them to the descriptor seems better, since it doesn't say "fix this". 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 >> >>> > But what would be the use case for that? When would you ever prefer to > write this rather than the first version? I guess if the slots are computed > -- but who uses computed slots nowadays? > I guess can't think of a compelling one. Maybe if you are one of those people who really doesn't like the typing stuff. It just seemed like an obvious way for the language to behave if things were modified such that these initialized values get stored somewhere for later use. However it just occurred to me: if it worked that way, how could you signal that the slot has no value? class C: __slots__ = dict(x = 0.0, y = None, z = <NO VALUE>)
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/W5TOXWGQPMEMYAZL33QBJA3I7J5RFQS7/ Code of Conduct: http://python.org/psf/codeofconduct/