Arnaud Delobelle <arno...@gmail.com> writes:

> >>> exec "a=2" in d
> assigning 2 to 'a'
> >>> d['a']
> 2
>
> >>> exec "global a; a = 3" in d
> >>> d['a']
> 3

Oooh, now isn't that an interesting wrinkle?  I've been careful (without
drawing attention) to restrict my arguments to variables inside
functions, largely because Python's global scopes work completely
differently.  (Python's global scopes work similarly to traditional Lisp
and Scheme, which isn't at all objectionable, but it's not the only way
of managing global scopes.  Queinnec's Lisp In Small Pieces describes
others.)

> So even if the globals() dictionary is custom, its __setitem__ method is
> *not* called.

Fascinating.  Thank you.

-- [mdw]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to