So this seems like it will make scope/namespaces a bit interesting...

Any good references on why this is this way?
I.e., why assignment passes across scopes instead of copy.
Or is it just explicit versus implicit?



On Jan 21, 2008 9:32 PM, John Fouhy <[EMAIL PROTECTED]> wrote:

> On 22/01/2008, John Morris <[EMAIL PROTECTED]> wrote:
> > I thought each class got it's own namespace and this sharing of mutable
> > objects is confusing me.
>
> Each class gets its own namespace, but names are different from
> objects.  For example:
>
> >>> x = [1, 2, 3]
> >>> y = x
> >>> y.append(4)
> >>> x
> [1, 2, 3, 4]
>
> In this case, x and y are both different names for the same object.
> Classes increase the name space, but they don't change the fact that
> in python, assignment is just giving something a new name.
>
> --
> John.
>



-- 
John Morris
[EMAIL PROTECTED]
"Do nothing which is of no use." -- Miyamoto Musashi
<a href="http://profile.mygamercard.net/nerdality";>
<img src="http://card.mygamercard.net/gbar/abyss/nerdality.gif"; border=0>
</a>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to