A Frame-space syntax ? - Re: global, globals(), _global ?

robert no-spam at no-spam-no-spam.com
Sun Mar 19 22:29:11 CET 2006


Marc 'BlackJack' Rintsch wrote:

> In <dve6ll$29l4$1 at ulysses.news.tiscali.de>, robert wrote:
> 
> 
>>The fact is:
>>* Python has that big problem with unnecessary barriers for nested frame 
>>access - especially painfull with callback functions where you want to 
>>put back data into the calling frame.
> 
> 
> You mean accessing the locals in the function that invoked the callback!? 
> That sounds ugly.  Makes it hard to decouple the caller and the callee
> here.
> 

That is a frequent need. For read's its anyway wired up. E.g. callbacks:

def f():
     a=1
     def g(var):
         print a             # automatic
         .lastvar=var        # binds in outer frame
     run_w_callback(1,2,g)
     print lastvar


Ruby blocks for example do that regularly.

Robert



More information about the Python-list mailing list