Feature request: String-inferred names

Carl Banks pavlovevidence at gmail.com
Tue Dec 1 15:52:19 EST 2009


On Dec 1, 10:21 am, Raymond Hettinger <pyt... at rcn.com> wrote:
> [Gregory Ewing]
>
> > >>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-wor...
>
> > I don't think getattr and setattr are used anywhere near
> > frequently enough to justify special syntax.
>
> Perhaps that would change if we had the proposed syntax.
> I would expect that powerful and expressive idioms would emerge.

I doubt it.  Such expressive idioms haven't emerged in languages that
do this (e.g., Javascript, Matlab) as far as I can tell.  The objects
end up being used as nothing more than a poor replacement for
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.")
>
> The proposed syntax works better with class namespaces
> which automatically provide inheritance logic and
> method binding.  Dictionaries don't provide equivalent
> support.

The right approach to having "inheritance-like behavior" AND
"typically don't know the name of the thing being accessed at compile
time" in the same object--and I doubt that would be widely useful--is
to add an option to dictionaries to support inheritance.


Carl Banks



More information about the Python-list mailing list