Proposal for adding symbols within Python
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Sun Nov 13 11:03:47 EST 2005
Björn Lindström a écrit :
> Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
>
>
>>I've yet to see a convincing argument against simply assigning values
>>to names, then using those names.
>
>
> The problem with that is that you can't pass around the names of objects
> that are used for other things. Obviously they make enums unnecessary,
> but only people damaged by non-dynamic languages could think that's the
> main point. ;-)
>
> Being able to do that precludes the need for converting going back and
> forth between strings and method names when you need to do things like
> keeping a list of function names, even when you need to be able to
> change what those function names point to.
>
> Python doesn't really need to introduce a new type to do this. It's
> already there, as what we usually just call names. Probably this
> discussion would benefit from talking about names rather than symbols,
> as that seems to confuse some people.
>
> So, Python already has symbols. What we need is a way to refer to these
> symbols explicitly. I would suggest to do it like in Lisp:
>
> quote(spam)
>
> Of course, this would preferably be implemented so that it doesn't just
> work on simple names:
>
> quote(spam(eggs))
>
> I syntactic sugar, like ' in Lisp, could be introduced later, but I
> don't think that would be strictly necessary.
>
Well, if this already exists in Python's internals, then, it would be
great just to expose them. Now, just being able to write :
>>> quote(spam)
quote(spam)
requires a new syntax so that spam is not resolved *before* calling the
quote method.
Pierre
More information about the Python-list
mailing list