I have some lines of python code that I\'m continuously copying/pasting into the python console. Is there a load
command or something I can run? e.g. load
If you're using IPython, you can simply run:
%load path/to/your/file.py
See http://ipython.org/ipython-doc/rel-1.1.0/interactive/tutorial.html
Python 3: new exec (execfile dropped) !
The execfile solution is valid only for Python 2. Python 3 dropped the execfile function - and promoted the exec statement to a builtin universal function. As the comment in Python 3.0's changelog and Hi-Angels comment suggest:
use
exec(open(<filename.py>).read())
instead of
execfile(<filename.py>)