Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread INADA Naoki
On Wed, Apr 25, 2018 at 12:04 PM, Nick Coghlan wrote: > On 25 April 2018 at 04:56, Ethan Furman wrote: >> On 04/24/2018 10:32 AM, Antoine Pitrou wrote: >> >>> Also beware the import time cost of having a widely-used module like >>> "warnings" depend on the

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Nick Coghlan
On 25 April 2018 at 04:56, Ethan Furman wrote: > On 04/24/2018 10:32 AM, Antoine Pitrou wrote: > >> Also beware the import time cost of having a widely-used module like >> "warnings" depend on the "enum" module and its own dependencies. > > > With all the recent changes to

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Ethan Furman
On 04/24/2018 10:32 AM, Antoine Pitrou wrote: Also beware the import time cost of having a widely-used module like "warnings" depend on the "enum" module and its own dependencies. With all the recent changes to Python, I should go through and see which dependencies are no longer needed. --

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 3:19 AM, Steven D'Aprano wrote: > On Wed, Apr 25, 2018 at 01:18:10AM +1000, Chris Angelico wrote: > >> First, though, can you enumerate (pun intended) the problems with >> magic strings? You list "no magic strings" as a benefit, as if it's >>

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Antoine Pitrou
On Tue, 24 Apr 2018 23:58:19 +1000 Nick Coghlan wrote: > On 24 April 2018 at 22:52, Jacco van Dorp wrote: > > A bit ago I was reading some of the python docs ( > > https://docs.python.org/3.6/library/warnings.html ), the warning > > module, and I

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Steven D'Aprano
On Wed, Apr 25, 2018 at 01:18:10AM +1000, Chris Angelico wrote: > First, though, can you enumerate (pun intended) the problems with > magic strings? You list "no magic strings" as a benefit, as if it's > self-evident; I'm not sure that it is. It shouldn't be self-evident, because the use of

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Nick Coghlan
On 25 April 2018 at 01:06, Jacco van Dorp wrote: > I guess we could add inconsistency as a con, then, since if the import > system isn't working at places where you'd like to use the Enums (or > even executing python code ?). This would mean that to the casual > observer,

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 1:06 AM, Jacco van Dorp wrote: > I > > 2018-04-24 15:58 GMT+02:00 Nick Coghlan : >> On 24 April 2018 at 22:52, Jacco van Dorp wrote: >>> Wouldn't it be cleaner to use enums by default instead of those magic

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Jacco van Dorp
I 2018-04-24 15:58 GMT+02:00 Nick Coghlan : > On 24 April 2018 at 22:52, Jacco van Dorp wrote: >> Wouldn't it be cleaner to use enums by default instead of those magic >> strings ? for example, for warnings filter actions, (section 29.5.2), >> quite near

Re: [Python-ideas] Change magic strings to enums

2018-04-24 Thread Nick Coghlan
On 24 April 2018 at 22:52, Jacco van Dorp wrote: > A bit ago I was reading some of the python docs ( > https://docs.python.org/3.6/library/warnings.html ), the warning > module, and I noticed a table of magic strings. > > I can think of a few other places where magic strings

[Python-ideas] Change magic strings to enums

2018-04-24 Thread Jacco van Dorp
A bit ago I was reading some of the python docs ( https://docs.python.org/3.6/library/warnings.html ), the warning module, and I noticed a table of magic strings. I can think of a few other places where magic strings are used - for example, string encoding/decoding locales and strictness, and