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 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor