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

rusi rustompmody at gmail.com
Wed Dec 4 01:31:44 EST 2013


On Wednesday, December 4, 2013 11:15:05 AM UTC+5:30, Tim Roberts wrote:
> Piotr Dobrogost  wrote:
> >
> >Attribute access syntax being very concise is very often preferred 
> >to dict's interface. 
>
> It is not "very concise".  It is slightly more concise.
>
>     x = obj.value1
>     x = dct['value1']
>
> You have saved 3 keystrokes.  That is not a significant enough savings to
> create new syntax.  Remember the Python philosophy that there ought to be
> one way to do it.

Its a more fundamental problem than that:
It emerges from the OP's second post) that he wants '-' in the attributes.
Is that all?

Where does this syntax-enlargement stop? Spaces? Newlines?



More information about the Python-list mailing list