How do I execute a string containing Python code in Python?
It's worth mentioning, that' exec's brother exist as well called execfile if you want to call a python file. That is sometimes good if you are working in a third party package which have terrible IDE's included and you want to code outside of their package.
Example:
execfile('/path/to/source.py)'
or:
exec(open("/path/to/source.py").read())