[Python-Dev] New syntax for 'dynamic' attribute access
Raymond Hettinger
python at rcn.com
Mon Feb 12 18:52:42 CET 2007
[Raymond Hettinger]
>> Rather than munge existing syntaxes, an altogether new one would be
>> more clear:
>>
>> self->name = self.metadata->name
[Ben North]
> One thing which comes to mind about this one is that, for C/C++
> programmers, the difference between
>
> obj.member and obj->member
>
> is the interpretation of the thing on the *left* of the dot or arrow,
> whereas the PEP is discussing a new interpretation of the thing on the
> *right* of the dot.
Try not to get hung-up on meanings from other languages.
Any simple syntax will have associations in other languages.
It is more important that we don't create a syntax which already
has strong associations in Python (i.e. curly braces, dots, and square
brackets).
Those syntaxes would make the language harder to mentally parse.
I would like to give the -> syntax a chance as is it simple
and it is provides a nice visual distinction between closely
related concepts:
a.name -- getattr(a, 'name')
a->name -- getattr(a, name)
Raymond
More information about the Python-Dev
mailing list