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

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 4 21:43:49 EST 2013


On Wed, Dec 4, 2013 at 3:09 AM, rusi <rustompmody at gmail.com> wrote:
> On Wednesday, December 4, 2013 2:27:28 PM UTC+5:30, Ian wrote:
>> On Tue, Dec 3, 2013 at 11:31 PM, rusi  wrote:
>> > 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?
>>
>> At non-strings.
>>
>> >>> setattr(foo, 21+21, 42)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>> TypeError: attribute name must be string, not 'int'
>
> Not sure what's your point.

There was no point.  My comment was only meant to be amusing.



More information about the Python-list mailing list