Python dot-equals (syntax proposal)

Lie Ryan lie.1296 at gmail.com
Sun May 2 02:28:28 EDT 2010


On 05/02/10 10:58, Steven D'Aprano wrote:
>> > And Python's object system
>> > makes it that the argument to __getattr__ is always a string even though
>> > there might be a valid variable that corresponds to it:
> That is nothing to do with the object system, it is related to the 
> semantics of Python syntax. a.b doesn't mean "apply the binary dot 
> operator to arguments a and b". It is syntactic sugar for "look for an 
> attribute named 'b' on object a". As such, the operands that __getattr__ 
> receives are the object a and the *name* b (implemented as a string).

You just described *exactly* the reason why dot is not, and cannot be an
operator.



More information about the Python-list mailing list