To run a python script in a python shell such as Idle or in a Django shell you can do the following using the exec() function. Exec() executes a code object argument. A code object in Python is simply compiled Python code. So you must first compile your script file and then execute it using exec(). From your shell:
>>>file_to_compile = open('/path/to/your/file.py').read() >>>code_object = compile(file_to_compile, '<string>', 'exec') >>>exec(code_object)
I'm using Python 3.4. See the compile and exec docs for detailed info.