Proposal for adding symbols within Python

Björn Lindström bkhl at stp.lingfil.uu.se
Sun Nov 13 10:28:31 EST 2005


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.

-- 
Björn Lindström <bkhl at stp.lingfil.uu.se>
Student of computational linguistics, Uppsala University, Sweden



More information about the Python-list mailing list