[Python-ideas] syntax for set

Masklinn masklinn at masklinn.net
Wed Nov 24 10:40:58 CET 2010


On 2010-11-24, at 10:02 , Georg Brandl wrote:
Am 24.11.2010 01:21, schrieb average:
>> On Mon, Nov 22, 2010 at 3:23 AM, Jan Kaliszewski <zuo at chopin.edu.pl
>> <mailto:zuo at chopin.edu.pl>> wrote:
>>> I'd be happy with:
>>> 
>>> * {:} for empty dict() (as a collection of key-value *pairs*)
>>> * {.} for empty set() (as a similar collection of *single* elements)
>>> 
>>> And {} for empty dict() as well -- to keep compatibility (maybe to be
>>> deprecated later).
>>    PS. Another argument: {} is criticized for its similarity to () (when using
>>    some fonts).
>> 
>> That is sometimes true, but one should bend towards fixing the font problem
>> rather than adapting to brokenness....
> 
> Yep. Otherwise you would also need to forbid "1" in identifiers because it
> can easily be confused with "l" in some fonts.  (And of course, let's not
> speak of identifiers in Python 3 in this context...)
> 
> Georg
> 
Since 1s will be in the code source in any case (as free-standing integers or as part of floats) wouldn't it be more sensible to ban `l` from identifiers? As well as uppercase O just to be on the safe side?

As an alternative, I would modestly propose banning integer literals altogether in favor of english-spelled constants: `ONE` can hardly be confused with the letter `l`, and having to write `FIVE HUNDRED FORTY-ONE BILLION FOUR HUNDRED FIFTY ONE MILLION NINE HUNDRED EIGHTY ONE THOUSAND NINE HUNDRED TWENTY ONE` rather than 514451981921 would surely reduce the usage of redundant magic numbers in the code.


More information about the Python-ideas mailing list