Feature request: String-inferred names

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Nov 26 02:28:06 EST 2009


> On Wed, 25 Nov 2009 20:44:36 -0600, The Music Guy
> <musicguy at alphaios.net> declaimed the following in
> gmane.comp.python.general:
> 
>>I just posted to my blog about a feature that I'd like to see added to
>>Python.
>>
>>http://alphaios.blogspot.com/2009/11/python-string-inferred-names-working.html

I don't think getattr and setattr are used anywhere near
frequently enough to justify special syntax.

To warrant having its own synax, a feature needs to be
used *all the time*. If you find yourself using getattr
and setattr that much, it's probably a symptom that
you're abusing namespaces for things that would be
better done using dictionaries.

(A frequent question asked by newcomers from certain
other kinds of languages is something like "How do I
assign to a variable whose name is in another variable?"
The answer is almost always "Don't do that, use a
dictionary.")

-- 
Greg



More information about the Python-list mailing list