Re: function parameter scope python 2.5.2

2008-11-21 Thread J Kenneth King
alex23 [EMAIL PROTECTED] writes: On Nov 21, 9:40 am, J Kenneth King [EMAIL PROTECTED] wrote: Of course, providing a shallow (or deep as necessary) copy makes it work, I'm curious as to why the value passed as a parameter to a function outside the class is passed a reference rather than a

Re: function parameter scope python 2.5.2

2008-11-21 Thread J Kenneth King
Steven D'Aprano [EMAIL PROTECTED] writes: On Thu, 20 Nov 2008 18:31:12 -0500, J Kenneth King wrote: Of course I expected that recursive_func() would receive a copy of weird_obj.words but it appears to happily modify the object. I am curious why you thought that. What made you think Python

Re: function parameter scope python 2.5.2

2008-11-21 Thread Peter Pearson
On Fri, 21 Nov 2008 10:12:08 -0500, J Kenneth King wrote: Steven D'Aprano [EMAIL PROTECTED] writes: I am curious why you thought that. What made you think Python should/did make a copy of weird_obj.words when you pass it to a function? [snip] Of course if there is any further reading on the

Re: function parameter scope python 2.5.2

2008-11-21 Thread J Kenneth King
Peter Pearson [EMAIL PROTECTED] writes: On Fri, 21 Nov 2008 10:12:08 -0500, J Kenneth King wrote: Steven D'Aprano [EMAIL PROTECTED] writes: I am curious why you thought that. What made you think Python should/did make a copy of weird_obj.words when you pass it to a function? [snip] Of

Re: function parameter scope python 2.5.2

2008-11-21 Thread Terry Reedy
J Kenneth King wrote: I was working on a program of some complexity recently and quickly caught the issue in my tests. I knew what was going on and fixed it expediently, but the behaviour confused me and I couldn't find any technical documentation on it so I figured I just didn't know what it

function parameter scope python 2.5.2

2008-11-20 Thread J Kenneth King
I recently encountered some interesting behaviour that looks like a bug to me, but I can't find the appropriate reference to any specifications to clarify whether it is a bug. Here's the example code to demonstrate the issue: class SomeObject(object): def __init__(self): self.words

Re: function parameter scope python 2.5.2

2008-11-20 Thread J Kenneth King
J Kenneth King [EMAIL PROTECTED] writes: I recently encountered some interesting behaviour that looks like a bug to me, but I can't find the appropriate reference to any specifications to clarify whether it is a bug. Here's the example code to demonstrate the issue: class

Re: function parameter scope python 2.5.2

2008-11-20 Thread alex23
On Nov 21, 9:40 am, J Kenneth King [EMAIL PROTECTED] wrote: Of course, providing a shallow (or deep as necessary) copy makes it work, I'm curious as to why the value passed as a parameter to a function outside the class is passed a reference rather than a copy. You're passing neither a

Re: function parameter scope python 2.5.2

2008-11-20 Thread George Sakkis
On Nov 20, 6:40 pm, J Kenneth King [EMAIL PROTECTED] wrote: J Kenneth King [EMAIL PROTECTED] writes: I recently encountered some interesting behaviour that looks like a bug to me, but I can't find the appropriate reference to any specifications to clarify whether it is a bug. Here's

Re: function parameter scope python 2.5.2

2008-11-20 Thread Rafe
On Nov 21, 6:31 am, J Kenneth King [EMAIL PROTECTED] wrote: I recently encountered some interesting behaviour that looks like a bug to me, but I can't find the appropriate reference to any specifications to clarify whether it is a bug. Here's the example code to demonstrate the issue: class

Re: function parameter scope python 2.5.2

2008-11-20 Thread Steven D'Aprano
On Thu, 20 Nov 2008 18:31:12 -0500, J Kenneth King wrote: Of course I expected that recursive_func() would receive a copy of weird_obj.words but it appears to happily modify the object. I am curious why you thought that. What made you think Python should/did make a copy of weird_obj.words

Re: function parameter scope python 2.5.2

2008-11-20 Thread Arnaud Delobelle
J Kenneth King [EMAIL PROTECTED] writes: I recently encountered some interesting behaviour that looks like a bug to me, but I can't find the appropriate reference to any specifications to clarify whether it is a bug. Here's the example code to demonstrate the issue: class