En Mon, 19 Feb 2007 00:08:45 -0300, placid <[EMAIL PROTECTED]> escribió:

> If anyone can provide a suggestion to replicate the following Tcl
> command in Python, i would greatly appreciate it.
>
> namespace eval foo {
>     variable bar 12345
> }
>
> what this does is create a namespace foo with the variable bar set to
> 12345.

Python namespaces are simple dictionaries. See the eval function.

py> s = "3+x**2"
py> freevars = {"x": 2}
py> eval(s, {}, freevars)
7

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to