On Thu, 14 Nov 2013 20:56:34 +, Rotwang wrote:
[...]
>> How about this?
>>
>> # module A.py
>> import inspect
>> def spam():
>> return inspect.stack()[1][0].f_globals
>
> Bump. Did this do what you wanted, or not?
Sort of. If anything, it convinced me that I don't, in fact, want what I
On 11/11/2013 12:02, sg...@hotmail.co.uk wrote:
(Sorry for posting through GG, I'm at work.)
On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote:
Suppose I have a function that needs access to globals:
# module A.py
def spam():
g = globals() # this gets globals from A
On 12/11/2013 01:57, Terry Reedy wrote:
On 11/11/2013 7:02 AM, sg...@hotmail.co.uk wrote:
(Sorry for posting through GG, I'm at work.)
On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote:
Suppose I have a function that needs access to globals:
# module A.py
def spam():
g
On 11/11/2013 7:02 AM, sg...@hotmail.co.uk wrote:
(Sorry for posting through GG, I'm at work.)
On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote:
Suppose I have a function that needs access to globals:
# module A.py
def spam():
g = globals() # this gets globals from A
(Sorry for posting through GG, I'm at work.)
On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote:
> Suppose I have a function that needs access to globals:
>
> # module A.py
> def spam():
> g = globals() # this gets globals from A
> introspect(g)
>
> As written, spam() o
On Mon, Nov 11, 2013 at 10:25 PM, Steven D'Aprano
wrote:
> But since spam is supposed to introspect as much information as possible,
> I don't really want to do that. What (if anything) are my other options?
You're playing with introspection, so I'd look at poking around in the
stack trace. It'll
Suppose I have a function that needs access to globals:
# module A.py
def spam():
g = globals() # this gets globals from A
introspect(g)
As written, spam() only sees its own globals, i.e. those of the module in
which spam is defined. But I want spam to see the globals of the caller.
#