Ok Hugo, so, going back to your example:
def nochange(some_list): # create shallow copy of list. NOTE: Shallow copies may still bite you if you change the list members. some_list = some_list[:] some_list[1] = 2 Here we've created a new list. It's an object in the global "object-space :)" but i can't access it outside the function because i don't have a name referring to it in the global namespace. Right? And, please let me ask a question: Kent told that nested_namespace(s) are default in python 2.6. And i found a line confirming this in py2.6 library. But, what about python 2.5 that as you know is the default on linux? Thankyou Giorgio 2010/2/23 Hugo Arts <hugo.yo...@gmail.com> > On Tue, Feb 23, 2010 at 2:28 PM, Giorgio <anothernetfel...@gmail.com> > wrote: > > Thankyou Hugo! > > Ok, so i think the key is of my problem is that when doing X = 0 i'm > > creating a new object, that only exist in the local namespace. BUT, when > > using a list as a parameter for a function i'm only giving it a new name, > > but the object it's referring to it's always the same, and is in the > global > > namespace. > > Right? > > Well, mostly, yes. It's important to see that it's not so much the > objects that live in namespaces, it's the names (otherwise they would > be called object-spaces, yes?). The objects do not live inside a > namespace, but are in a conceptually separate place altogether. A name > lives in a namespace, and can only be referenced inside that space. An > object can be referenced from anywhere, as long as you have a name > that points to it. > > So, when you're doing x = 0, you're creating a new object, and the > name x (in the local namespace) points to that object. That doesn't > mean the object itself is confined to the local namespace. You could > write 'return x', which allows you to have a name in the global > namespace point to that same object. > > Hugo > -- -- AnotherNetFellow Email: anothernetfel...@gmail.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor