Why is there no natural syntax for accessing attributes with names not being valid identifiers?

Neil Cerutti neilc at norwich.edu
Fri Dec 6 15:07:51 CET 2013

On 2013-12-04, Piotr Dobrogost
<p at google-groups-2013.dobrogost.net> wrote:
> On Wednesday, December 4, 2013 10:41:49 PM UTC+1, Neil Cerutti
> wrote:
>> not something to do commonly. Your proposed syntax leaves the
>> distinction between valid and invalid identifiers a problem
>> the programmer has to deal with. It doesn't unify access to
>> attributes the way the getattr and setattr do.
> Taking into account that obj.'x' would be equivalent to obj.x
> any attribute can be accessed with the new syntax. I don't see
> how this is not unified access compared to using getattr
> instead dot...

I thought of that argument later the next day. Your proposal does
unify access if the old obj.x syntax is removed.

Neil Cerutti

More information about the Python-list mailing list