Antoon Pardon wrote: >>Because b.a += 2 expands to b.a = b.a + 2. Why would you want b.a = >><something> to correspond to b.__class__.a = <something>? > > > That is an implemantation detail. The only answer that you are given > means nothing more than: because it is implemented that way.
Something that is written in the language reference is not an implementation detail. Every implementation that aims to be Python must follow this. It's a design decision. Whether you like it or not, you will find out that the behaviour of Python is largely based on an idea of an underlying structure. A lot of the syntax is basically just convenient ways to access this structure, and there is a strong tradition to avoid magic. The explicit use of self might be the most obvious example of that, but you can find a lot of other things in Python that shows you this, __dict__ for instance. I agree that the behaviour you are questioning isn't completely unsurprising for someone who stumbles over it the first time, but considering how things work in Python classes, where the class scope is searched if a name isn't found in the instance scope (self.__dict__), any other solution would involve more magic, and be more surprising to someone who actually knows what is going on. It's possible that a oldie like me, who started coding Python in 1996 is just blind to the warts in Python by now, but no language is perfect, and whatever design decisions you make, they will have both positive and negative consequences. I frankly don't understand what you are after Antoon. Just to vent your frustrations? If you want to use Python in an effective way, try to learn how to use the language that actually exists. Asking questions in this forum is clearly a part of that, but your confrontational style, and idea that everything that bothers you is a language bug that needs to be fixed is not the most constructive approach. I'm pretty sure that it doesn't really solve your coding problems, instead it leads the discussion away from the practical solutions. If you really want to improve the Python language, your approach is completely off target. First of all, this isn't really the right forum for that, and secondly, improvements to Python requires a lot of cooperation and substantial contributions of work, not just complaints, even if you might have a point now and then. -- http://mail.python.org/mailman/listinfo/python-list