[Python-ideas] Change magic strings to enums

Jacco van Dorp j.van.dorp at deonet.nl
Thu Apr 26 02:55:01 EDT 2018


Even if not just for the autocompletion, it would be more explicit
that it's not just a random string like you'd pass to print(), but it
has a specific meaning. Something in PEP 20 about explicit and
implicit ?

Autocompletion might be a good advantage, but 1) the IDE would need to
know what to autocomplete it to, and you probably shouldn't
special-case the stdlib like you'd need to with strings, and 2) enums
-are- more explicit. When there's a distinct and limited set of
options, they're just the tool for the job. (or at least, a much
better tool for this job than to remember colors, which is used all
over their documentation).

Im naming auto-completion here as a solid reason, but when clean code
itself can be considered a solid reason, I think that's probably the
real reason.

2018-04-26 1:11 GMT+02:00 Soni L. <fakedme+py at gmail.com>:
>
>
> On 2018-04-25 12:05 PM, Guido van Rossum wrote:
>
> On Wed, Apr 25, 2018, 02:13 Jacco van Dorp <j.van.dorp at deonet.nl> wrote:
>>
>> ... Which is where the auto-completion comes in. ...
>
>
> Designing the language with auto-complete in mind feels wrong to me. It
> assumes a very sophisticated IDE and may lead to lazy design compromises.
>
>
> You can tab-complete enums (in the REPL), but not strings.
> Tab-complete is not an IDE thing, it's a CPython REPL thing. It seems
> reasonable to design for it.
>
> Any IDE worth my time would support string autocompletion, anyway. ;)
>
>
> --Guido
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>


More information about the Python-ideas mailing list