Return value of an assignment statement?

George Sakkis george.sakkis at
Fri Feb 22 07:02:01 CET 2008

On Feb 22, 12:26 am, Jeff Schwab <j... at> wrote:

> > On the other hand, "a = b" does always the same thing; unlike C++, '='
> > is not an operator and therefore it cannot be overriden by the class
> > of 'a'.
> "Not an operator?"  Then what is it?

In this context, it's just the token used for the assignment
statement. In short, if 'a' is an identifier, the statement means
"bind the name 'a' to the object 'b' (in the local or global
namespace)". It doesn't say anything about memory allocation,
initialization or copying. The only case where assigning an identifier
affects memory is the following [1]:

The name is rebound if it was already bound. This may cause the
reference count for the object previously bound to the name to reach
zero, causing the object to be deallocated and its destructor (if it
has one) to be called.



More information about the Python-list mailing list