[Python-ideas] Keyword/Symbol literals

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jan 21 21:57:41 CET 2015


Steven D'Aprano wrote:
> On Tue, Jan 20, 2015 at 11:48:58PM -0800, Stephen Hansen wrote:
> 
>>What does :foo get you that 'foo' doesn't?
> 
> It gets you an atomic data type which isn't a string and isn't an int.

If you want that, you're better off creating your own
class. Otherwise, there's nothing to distinguish symbols
used for one purpose from symbols used for another, which
is the same problem recurring at another level.

> Python already has a number of symbol-like objects in the language:
> 
> None
> True and False
> NotImplemented
> Ellipsis

And it's not hard to create more, especially now that we
have Enums as a provided battery.

-- 
Greg


More information about the Python-ideas mailing list