[Tutor] dictionaries, objects and scoping...

John Morris jrmorrisnc at gmail.com
Tue Jan 22 04:28:07 CET 2008

Thanks. I think this is understood better now.

Thanks to everyone for their help. I was running low on ways to express this
for clearer understanding.

Awesomeness once again from tutor at python.org.

- John

On Jan 21, 2008 10:18 PM, Kent Johnson <kent37 at tds.net> wrote:

> John Morris wrote:
> > Ahhh. so namespaces are scoped, not objects...
> I would say names are scoped, but I guess namespaces are too.
> > You have to keep your objects separate (and make copies when needed),
> Yes
> > Python just keeps namespaces (names that refer to an object) scoped
> > according to it's rules:
> > http://docs.python.org/ref/naming.html
> >
> > So if you create an object way up in terms of scope (global), then all
> > python does is handle what names are available in a given scope to refer
> > to it. If you want a separate object you have to take care of that
> > yourself. Efficient.
> Yes. Assignment is not copying, it is name-binding.
> > Massive potential for gotchas, especially with some
> > of python's cleverness in terms of scoping rules.
> In my experience it is rare to actually need a copy of an object, and
> usually pretty clear when I do. The real hurdle is getting your mental
> model in sync with what Python is actually doing, rather than what you
> think it should be doing.
> Kent

John Morris
jrmorrisnc at gmail.com
"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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080121/54242be0/attachment.htm 

More information about the Tutor mailing list