Casebash
Casebash

Reputation: 118972

Nice copying from Python Interpreter

When I am working with a Python Interpreter, I always find it a pain to try and copy code from it because it inserts all of these >>> and ...

Is there a Python interpreter that will let me copy code, without having to deal with this? Or alternatively, is there a way to clean the output.

Additionally, sometimes I would like to paste code in, but the code is indented. Is there any console that can automatically indent it instead of throwing an error?

Related

Upvotes: 7

Views: 625

Answers (5)

Ants Aasma
Ants Aasma

Reputation: 54935

IPython lets you show, save and edit your command history, for example to show the first three commands of your session without line numbers you'd type %hist -n 1 4.

Upvotes: 4

Alex Martelli
Alex Martelli

Reputation: 882701

I have a vim macro to "paste while cleaning interpreter prompts and sample output [[==stuff NOT preceded by prompts" and I'll be happy to share it if vim is what you're using. Any editor or IDE worth that name will of course be similarly easy to program for such purposes!

Upvotes: 1

Nicholas Riley
Nicholas Riley

Reputation: 44351

IPython will let you paste Python code with leading indents without giving you an IndentationError. You can also change your prompts to remove >>> and ... if you wish.

Upvotes: 1

Arkady
Arkady

Reputation: 15079

WingIDE from Wingware will let you evaluate any chunk of code in a separate interpreter window.

Upvotes: 3

thereisnospork
thereisnospork

Reputation: 193

Decent text editors such as Notepad++ can make global search and replace operations that can replace >>> with nothing.

Upvotes: 0

Related Questions