[Python-Dev] New syntax for 'dynamic' attribute access
Gustavo Carneiro
gjcarneiro at gmail.com
Mon Feb 12 12:20:41 CET 2007
On 2/11/07, Ben North <ben at redfrontdoor.org> wrote:
>
> Hi,
>
> A few days ago I posted to python-ideas with a suggestion for some new
> Python syntax, which would allow easier access to object attributes
> where the attribute name is known only at run-time. For example:
>
> setattr(self, method_name, getattr(self.metadata, method_name))
>
> from Lib/distutils/dist.py could be rewritten
>
> self.(method_name) = self.metadata.(method_name)
>
> The new syntax would also be usable in augmented assignments, as in
>
> obj.(attr_name) += 1
>
-1 from me. It does not solve a common problem, therefore it does not
deserve a special syntax. Moreover, the existing syntax may be longer to
type but is far more readable.
--
Gustavo J. A. M. Carneiro
"The universe is always one step beyond logic."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070212/680055fe/attachment.html
More information about the Python-Dev
mailing list