FAQ: How do I calculate what quoted strings and numbers mean?
Fredrik Lundh
fredrik at pythonware.com
Wed Nov 15 03:37:48 EST 2006
p.lavarre at ieee.org wrote:
> I was happy enough when I saw an improvement like:
>
>>>> import os
>>>> result = eval("os.system('pwd')")
> .../Desktop
>>>> result = eval("os.system('pwd')", {"whatever": {}})
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<string>", line 1, in <module>
> NameError: name 'os' is not defined
sure, but the os module isn't very far away:
>>> result = eval("__import__('os').system('pwd')", {"whatever": {}})
/home/fredrik
</F>
More information about the Python-list
mailing list