Clipboard paste Python script to IPython shell

If you've attempted to paste before you'll know that Python's signifcant whitespace can cause issues with the Python/IPython shell's autoindent. IPython has two magic utilities built-in called %paste (requires Tkinter) and %cpaste (for CLI/remote access). If you have a code snippet that you want to run without having to type it in one-line-at-a-time or you're running a one-off script for Django that doesn't necessitate a manage.py command these will do the trick.

Django will automatically use the IPython shell when manage.py shell is invoked, so if it's installed in your current virtualenv this should work fine. If you're running via an SSH session you'll want to use the %cpaste command as the Tkinter-powered %paste requires an X server to be running.

If you don't have IPython installed it's a simple pip install ipython. I also recommend installing its counterpart, ipdb: the IPython debugger (pip install ipdb). From the package description: "ipdb exports functions to access the IPython debugger, which features tab completion, syntax highlighting, better tracebacks, better introspection with the same interface as the pdb module."