Modifying Class Object

Steve Holden steve at holdenweb.com
Mon Feb 8 07:01:42 EST 2010


Gerard Flanagan wrote:
> Arnaud Delobelle wrote:
>> "Alf P. Steinbach" <alfps at start.no> writes:
>>
>>> * Chris Rebert:
>>>> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything at gmail.com> 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
>>>> http://effbot.org/zone/call-by-object.htm for a excellent explanation
>>>> of what Python does use.
>>> Hm. While most everything I've seen at effbot.org 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.
>>
>>
>> Please! Not this again! This has been discussed to death and beyond more
>> than enough times.  Go search the c.l.p archives, read it all, and I'm
>> sure you won't want to add anything anymore.
>>
> 
> +1 !!
> 
+1000
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list