newbie needs help on dictionary

Fredrik Lundh fredrik at pythonware.com
Fri Dec 10 06:04:42 EST 1999


Olaf Appelt <tholap at compuserve.com> wrote:
> I'm new to Python so take this with moderate amounts of salt:
> 
> > count = turret[station][tool_name]
> > count = count + 1
> > turret[station][tool_name] = count
> 
> 'count' is not a copy of 'turret[station][tool_name]', it's a reference.
> So the following should result in the same thing:

nope.

> > count = turret[station][tool_name]

after this statement, "count" is a reference.

> > count = count + 1

but after this statement, "count" is rebound to
point to a newly created integer object.  the
dictionary still points to the *original* value.

</F>





More information about the Python-list mailing list