mutable member, bug or ...

Fredrik Lundh fredrik at pythonware.com
Sun Jun 4 12:51:34 EDT 2006


Sambo wrote:

> By accident I assigned int to a class member 'count' which was
 > initialized to (empty) string and had no error till I tried to
 > use it as string, obviously. Why was there no error on assignment
 > (near the end ).

Python uses dynamic typing, which means that objects have types, but 
variables don't.  A variable is just a name.

I suggest reading up on variables, namespaces and classes/instances in 
your favourite tutorial.  Python's not C++, and you won't get very far 
by pretending that it is.

</F>




More information about the Python-list mailing list