function parameter scope python 2.5.2

J Kenneth King james at
Fri Nov 21 16:12:08 CET 2008

Steven D'Aprano <steve at> 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 should/did 
> make a copy of weird_obj.words when you pass it to a function?
> This is a serious question, I'm not trying to trap you into something :)

Don't worry, I don't feel "trapped" in usenet. ;)

It was more of an intuitive expectation than a suggestion that Python
got something wrong.

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
was referred to in Python. Hence the post. :)

I suppose I have some functional sensibilities and assumed that an
object wouldn't let a non-member modify its properties even if they were

Of course if there is any further reading on the subject, I'd appreciate
some links.


More information about the Python-list mailing list