Skip to content

Commit

Permalink
eval-exec.py: Added demonstration of importing
Browse files Browse the repository at this point in the history
  • Loading branch information
von committed May 1, 2014
1 parent 8bcc2c1 commit 6d1ca36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/eval-exec.py
Expand Up @@ -7,3 +7,11 @@
# Setting a value needs to be done with exec()
exec("a=2")
print eval("a+4")

# Dynamically import modules
for module in [ "os", "sys" ]:
exec("import {}".format(module))

# And show above worked...
os.chdir("/") # noqa
print sys.copyright # noqa

0 comments on commit 6d1ca36

Please sign in to comment.