[Python-ideas] Keyword/Symbol literals
Guido van Rossum
guido at python.org
Wed Jan 21 18:42:02 CET 2015
Yeah, basically this was a fork in the road roughly 25 years ago that
Python didn't take. (I was aware of the idea from Lisp, and decided Python
could do with just strings instead.) There's no way adding something like
this today will suddenly change everything else that is part of having
"symbols"; the proposed feature would be lacking the integration with the
internals that makes it work well in some other languages.
On Wed, Jan 21, 2015 at 1:13 AM, Andrew Barnert <
abarnert at yahoo.com.dmarc.invalid> wrote:
> On Jan 20, 2015, at 23:48, Stephen Hansen <me+python at ixokai.io> wrote:
>
> *What do people do now?*
>> or strings
>>
>> df.sort('name')
>>
>
> ...
>
>
>> strings work but feel unpleasant
>>
>
> Why?
>
> What does :foo get you that 'foo' doesn't?
>
> One character being saved doesn't seem like a good reason to add syntax.
>
>
> Mainly they're used to fill in gaps where a language isn't dynamic enough
> to just use strings, which Python doesn't need.
>
> (Sometimes this is claimed to be a strength rather than a weakness. Arguably,
> using auto-interned symbols instead of strings for things like attribute or
> global lookup could be more efficient, but I don't think languages like
> Ruby have shown any demonstrable gain. And we just had a thread from
> someone who considered it a "bug" that Python allows setattr(spam, '3', 3)
> when 3 isn't a valid identifier, which symbols "fix" automatically. But
> even if these were real advantages, Python obviously isn't going to make
> such a radical change as banning strings for dynamic access.)
>
> A language can also add things on top of the symbol/string distinction
> (besides auto-interning)--e.g., you can add syntactic sugar for dynamic
> lookup ("foo.:bar" means "getattr(foo, bar)"), or make undefined
> variables have the value of their symbol so you can LBYL test them, or all
> kinds of other things--but again, they're all things I don't think Python
> wants or needs.
>
> And without a vague idea for why Python would want to do any of the things
> that other languages do with their symbol-vs.-string distinctions, this
> really does seem to come down to just saving one character.
>
> _______________________________________________
> 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/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150121/88320917/attachment.html>
More information about the Python-ideas
mailing list