Modifying Class Object

Alf P. Steinbach alfps at
Mon Feb 8 20:10:00 CET 2010

* Diez B. Roggisch:
> Am 08.02.10 02:51, schrieb Alf P. Steinbach:
>> * Chris Rebert:
>>> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything at> wrote:
>>>> Ok, just looking for a sanity check here, or maybe something I'm
>>>> missing. I have a class Test, for example:
>>>> class Test:
>>>> def __init__(self, param1, param2, param3):
>>>> self.param1 = param1
>>>> self.param2 = param2
>>>> self.param3 = param3
>>>> Next, I have a dictionary mytest that contains instances of Test. If
>>>> I want to modify one of the Test instances within my dictionary, I
>>>> have to rewrite the entire entry, correct (since Python passes by
>>>> value, not reference)?
>>> Incorrect; Python uses neither. See
>>> for a excellent explanation
>>> of what Python does use.
>> Hm. While most everything I've seen at has been clear and to
>> the point, that particular article reads like a ton of obfuscation.
>> Python passes pointers by value, just as e.g. Java does.
>> There, it needed just 10 words or so. :-) Or perhaps some more words to
>> point out that in the Java language spec those reference values are
>> called pointers, but that this terminology isn't (apparently) used for
>> Python, and isn't even well known among Java programmers. But that's
>> just one extra little para.
>> One just has to be clear about exactly what it is that's passed by value.
>> Not Python objects, but references (pointers) to them, the id(o) values.
> Whao. You just needed 10 words, plus a paragraph to explain something in 
> terms of a spec that's just about 600 pages strong. Amazing display of 
> conciseness, and certainly the most valuable thing for some programming 
> newbie to work with. Thanks!

I apologize for assuming that "pointer" is a known word to [c.l.p.] denizens.

But, if it can help, although for clarity I had to provide a concrete reference, 
you don't need to read the complete Java language spec to understand that word.

Just Google it.

Cheers & hth.,

- ALf

More information about the Python-list mailing list