The run command executes a Python file and loads the variables into the current namespace.
In [10]: !cat file.py #!/usr/bin/env python a = 12 In [11]: run file.py In [12]: a Out[12]: 12