Paste code into Python Interpreter

I’ve come up with various theories about why pasting into python doesn’t work, but finally, I discovered iPython’s %cpaste command.

%paste pastes content from your clipboard, but doesn’t work in a remote environment.

Enter %cpaste.

In [109]: %cpaste
Pasting code; enter '--' alone on the line to stop.
: print(Paste Stuff Here)

Enter — and the paste ends cleanly… amazing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s