On Sat, Dec 21, 2013 at 12:56 PM, <tutor-requ...@python.org> wrote:

> py> x = 23
> py> d = globals()
> py> d['x']
> 23
> py> d['x'] = 42
> py> x
> 42
>


Well this is sort of fascinating, but a bit confusing: I was playing with
this, and it seems like the global dictionary includes not just the name
but the entire contents of every dictionary within it... that seems
implausibly redundant, so maybe that's just something about how exploring a
dictionary functions recursively, or something? Maybe it's correct to say
that any dictionaries within a namespace are stored in that namespace,
though that doesn't really sound right.

>>> d = globals()
>>> fubar = {1: 'spam', 'eggs': 2}
>>> d
{'__name__': '__main__', '__builtins__': <module 'builtins' (built-in)>,
'__doc__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>,
'fubar': {1: 'spam', 'eggs': 2}, 'd': {...}, '__package__': None}

And yes, I did change up my string/int order in key/value positions: I'm
fascinated by the flexibility of the data structure. I suspect the answer
to my question lies in exactly this facet.

-- 
Keith
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to