Created
June 30, 2015 19:28
-
-
Save mattbennett/f57a5286bd77ee52651e to your computer and use it in GitHub Desktop.
coverage.py exec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(): | |
print "foo" | |
def bar(): | |
print "bar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "the answer to life, the universe and everything is: {}".format(undeclared_var) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from impl import foo | |
foo() | |
namespace = { | |
'undeclared_var': 42 | |
} | |
with open('impl2.py') as f: | |
code = compile(f.read(), 'impl2.py', 'exec') | |
exec(code, globals(), namespace) |
Author
mattbennett
commented
Jun 30, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment