A.x vs. A["x"]

Martin Drautzburg Martin.Drautzburg at web.de
Fri Jan 22 14:29:13 EST 2010


This has probably been asekd a million times, but if someone could give
a short answer anyways I's be most grateful.

What is it that allows one to write A.x? If I have a variable A, then
what to I have to assign to it to A.x becomes valid?

Or even further: what do I have to do so I can write A.x=1 without
having done anything magical for x (but just for A)? I know you can do
this with classes, but not with plain objects, but why is that so?



More information about the Python-list mailing list