Counterintuitive Python behavior
Sean 'Shaleh' Perry
shalehperry at attbi.com
Wed Apr 17 09:44:39 EDT 2002
On 17-Apr-2002 Max M wrote:
> dominikush at yahoo.com wrote:
>
>> Who is wrong here: my intuition or Python (2.2)? If it's
>> my intuition, how can I train my thinking about Python's
>> execution model, so that my intuition get's better ;-)
>
> Your intuition!
>
> Objects like lists gets copied by reference. So Python behaves exactly
> like it should.
>
Or from another side:
a = [...]
b = a
b[n] = ...
and a gets updated. values() returns the contents of the dictionary so you are
seeing the same type of behaviour.
More information about the Python-list
mailing list