I love this idea. It makes `__slots__` easy and efficient to define! The
current, explicit syntax is very tedious and verbose.

`__slots__ = ...` is a very clear syntax for saying "Include ALL annotated
class-variables automatically".

It would relegate manual `__slots__ = { "a", "b" }` usage to when you want
to define slots without annotating the variables, which pretty much nobody
does.

So in effect, this new syntax would mean that everyone who wants slots in
their classes will use the easy triple-dot syntax!

It would be a very nice language improvement.

(The `@dataclass` system itself still needs a way to allow "default
variable values" (in the auto-generated `__init__`) if slots are used,
though...)



Den lör 28 sep. 2019 kl 05:12 skrev Guido van Rossum <gu...@python.org>:

> On Fri, Sep 27, 2019 at 8:01 PM MRAB <pyt...@mrabarnett.plus.com> wrote:
>
>> I was also thinking about suggesting None, but I was wondering whether
>> that could be misleading because it reads like "no slots".
>>
>> What about "..." instead? Would that read better?
>>
>> class Point:
>>      __slots__ = ....
>>      x: float
>>      y: float
>>
>
> Not bad!
>
> --
> --Guido van Rossum (python.org/~guido)
> *Pronouns: he/him **(why is my pronoun here?)*
> <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
> _______________________________________________
> 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/RJQG2EFXZCQBJ74XKKB6IJAN4PSAJJLO/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/AAFKGU2SZPWVZXN6S3VFDERNS77QECG2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to