From: Steve Holden on
Gerard Flanagan wrote:
> Arnaud Delobelle wrote:
>> "Alf P. Steinbach" <alfps(a)start.no> writes:
>>
>>> * Chris Rebert:
>>>> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything(a)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/

From: Alf P. Steinbach on
* Steve Holden:
> Alf P. Steinbach wrote:
>> * Steve Holden:
> [...]
>>> Alf:
>>>
>>> This topic was discussed at great, nay interminable, length about a year
>>> ago. I'd appreciate it if you would search the archives and read what
>>> was said then rather than hashing the whole topic over again to nobody's
>>> real advantage.
>> Well that's my point, and thanks for backing me up on that :-): it's
>> very simple, and as demonstrated can be expressed in 10 words or less
>> (plus perhaps a terminology reference, as I did above), so all that
>> discussion and in particular the lengthy article at effbot serves as
>> obfuscation and nothing else.
>>
> Please don't assume I was trying to support you. Your remarks showed
> considerable ignorance of issue that were extremely nuanced. Whatever
> point you were trying to make was lost in your self-aggrandizing
> disrespect of Fredrik Lundh, a software engineer of some repute with a
> long history of contribution to Python. The fact that your post was
> basically a restatement of one of the several competing positions in
> that thread makes it no more right than any of the others.

What on Earth are you babbling about?

Perhaps next you'll drag in the Pope, saying I've shown him some disrespect.

News for you: the Pope ain't participating.


>> By the way, most every programming language has some corner like that,
>> something that is utterly simple but somehow has some kind of
>> obfuscation-meme attached.
>>
> Why thank you for the education. Somehow in my 40-odd years of
> programming I had quite overlooked that fact. Which helps how?
>
>> In C++ it's "call" and "constructor". It doesn't help that the
>> language's standard lays down the law on it, it doesn't help that the
>> language's creator has laid down the law, it doesn't help that it's
>> utterly and completely simple. Somehow newbies and even some experienced
>> people manage to create their own terminological nightmare and drawing
>> conclusions about reality from that misguided obfuscated view, and then
>> discussing it up and down and sideways.
>>
> Which IMHO you have done little to assist. Just how exactly *do* we
> succeed in asking you not to discuss something?

That's just a silly as the above. Hello? *Not* discuss an on-topic topic?

Anyways, we haven't reached discussion yet, if it will ever come to that.

All I see is a lot of silly noise about a simple trivially true technical
statement, with incoherent allegations of disrespect to the Pope, the current
king of France, and whomever, unfortunately as usual in this group. :-(



Cheers & hth.,

- Alf
From: Duncan Booth on
T <misceverything(a)gmail.com> wrote:
> Duncan - Thanks for your help. So each of the shelve entries I'm
> modifying look something like this: myshelve[key]
> TestClassObject(param1, param2, param3, param4, param5, etc.). In
> this case, with quite a few parameters, would you suggest setting
> writeback=True and just modifying the needed value, or rewriting the
> entire entry? I have to admit the writeback option looks good, and if
> the TestClassObject format ever changes (i.e. if I ever change the
> order of the params), this particular function will be unchanged.
> However, I don't know what the performance hit would be in using it.

Only you know your data and pattern of use. Try a few tests to get a feel
of the trade-offs between explicitly flagging items as changed or using
writeback=True.
From: Diez B. Roggisch on
Am 08.02.10 02:51, schrieb Alf P. Steinbach:
> * Chris Rebert:
>> On Sun, Feb 7, 2010 at 5:05 PM, T <misceverything(a)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.
>
> 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!

Diez
From: Alf P. Steinbach on
* 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(a)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.
>>
>> 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