Variable scope and caller

Erik Max Francis max at alcyone.com
Mon Dec 16 02:13:49 EST 2002


Mike Meyer wrote:

> One is the Shell-like expansion of variables in a string. The closest
> you can get to that is %-expansion with a dictionary:
> 
>         a = "hello %(b)s"
>         b = "erik"
>         print a % globals()
>         b = "moon"
>         print a % globals()
> 
> will give you the output you asked for.

I'm thinking you meant locals() in both cases here.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Do we really want to go to Mars / Do we really want to try
\__/ Cassandra Wilson
    CSBuddy / http://www.alcyone.com/pyos/csbuddy/
 A Counter-Strike server log file monitor in Python.



More information about the Python-list mailing list