On 1 June 2016 at 16:10, Sven R. Kunze srkunze@mail.de wrote:
That's the current way. If now, the compiler would assign "x" to a special dunder attribute/variable, that would allow __init__ to extract that name and use it as if it were a parameter:
class AutoSymbol: def __init__(self): self.name = __assigned_name__ # that's me :)
Why doesn't the assignment here set __assigned_name__ too, and override the value assigned by the "outer" assignment?
Also, as someone else pointed out, in
a = b = c = AutoSymbol()
what would __assigned_name__ be? The advantage of a special operation is that it gives you a way of pointing out precisely *which* name assignment we want to remember...
Paul