IDLE history, Python IDE, and Interactive Python with Vim

A

Ashot

This is sort of both Python and Vim related (which is why I've posted to
both newsgroups).

Python related:
----------------------
I have been frustrated for quite some time with a lack of a history
command in IDLE (in fact with IDLE in general). Often I'll develop new
code at the command line, testing each line as I go. Currently I have to
copy and paste, removing outputs and the ">>>" at each line.
Is it perhaps possible to make some kind of hack to do this (dump a
command history)?

Idle in general isn't that great IMO, so I was wondering also if there are
better alternatives out there? What do people use mostly? I've tried
something called pyCrust, but this too didn't have history and some other
things I was looking for. On a more general note, although the agility
and simplicity of Python make programming tools like an IDE less
necessary, it still seems that Python is lacking in this departement. The
PyDev plug-in for Eclipse seems like good step in this direction, although
I haven't tried it yet. Does anyone have any experience with this, or
perhaps can point me to other tools.

Vim related:
----------------------
Ideally, it would be nice to have a command mapped to a keystroke that can
append the last executed command to a file. Even better would be a system
that would integrate the file editing and interactive command line tool
more seamlessly. Something along the lines of a debugger + file editor
+ command line utility, where file editor = vim. I know that vim has a
utility for running python commands from its command prompt, but I have
had a hard time getting this to work in windows and haven't explored it.
Has anyone seen/tried a system along these lines, perhaps incorporating
the python debugger (pdb)? I can see something that will run the file you
are editing in vim up to the cursor or a mark with a set_trace at the line
you are editing.


Any info is appreciated, thanks.
 
D

Daniel Bickett

This is certainly a worthy topic. There are several IDEs for Python
(one I like very much being Komodo) that have plenty of fancy
debugging features and advanced operations, however I have yet to
encounter (elsewhere) the convenience that comes with being able to
press F5 and have an interactive interpreter load my code and be ready
for testing.

That said, that is my only reason for my ever using IDLE. Without it I
would probably forget that IDLE exists, were it not for the obnoxious
context menu entry. ;)
 
S

Stephen Waterbury

Daniel said:
This is certainly a worthy topic. There are several IDEs for Python
(one I like very much being Komodo) that have plenty of fancy
debugging features and advanced operations, however I have yet to
encounter (elsewhere) the convenience that comes with being able to
press F5 and have an interactive interpreter load my code and be ready
for testing.

*Sigh*, I too am a vi kinda guy, and I keep badgering the WingIDE
gang to give Wing a vi mode ... :) They keep saying "it's coming",
but it's been a while ... and in fairness to them, I don't think
there is exactly a huge horde of vi barbarians at their gate!
Probably a pretty tiny horde, and not very noisy. ;)

Steve
 
A

Ashot

WingIDE looks nice though, and it seems that the interactive shell is
built in from the screenshots. Can you run a program to a certain point
break point and use the shell?

*Sigh*, I too am a vi kinda guy, and I keep badgering the WingIDE
gang to give Wing a vi mode ... :) They keep saying "it's coming",
but it's been a while ... and in fairness to them, I don't think
there is exactly a huge horde of vi barbarians at their gate!
Probably a pretty tiny horde, and not very noisy. ;)

Steve



--
==============================
Ashot Petrosian
University of Texas at Austin, Computer Sciences
(views expressed are solely my own)
==============================
 
P

Pierre Barbier de Reuille

Fuzzyman a écrit :
If you use IPython for your interactive mode stuff, you'll have a nice
history...
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Best event : if your "EDITOR" system variable in "vim", using the "ed"
command in ipython will bring "vim" with (eventually) the code you want
to edit :)

Now, I wonder if you could embed ipython inside vim ...

Pierre
 
B

Bruno Desthuilliers

Daniel Bickett a écrit :
This is certainly a worthy topic. There are several IDEs for Python
(one I like very much being Komodo) that have plenty of fancy
debugging features and advanced operations, however I have yet to
encounter (elsewhere) the convenience that comes with being able to
press F5 and have an interactive interpreter load my code and be ready
for testing.

Try emacs + python-mode.
 
B

Bruno Desthuilliers

Pierre Barbier de Reuille a écrit :
Fuzzyman a écrit :


Best event : if your "EDITOR" system variable in "vim", using the "ed"
command in ipython will bring "vim" with (eventually) the code you want
to edit :)

Now, I wonder if you could embed ipython inside vim ...

<holy-war>
Don't know, but you can embed ipython inside emacs !-)
 
R

Richie Hindle

[Ashot]
I have been frustrated for quite some time with a lack of a history
command in IDLE

To recall a line from your history in IDLE, cursor up to that line and hit
Enter.
I've tried something called pyCrust, but this too didn't have history

To recall a line from your history in PyCrust, press Ctrl+UpArrow.
 
S

Steve Holden

Ashot said:
WingIDE looks nice though, and it seems that the interactive shell is
built in from the screenshots. Can you run a program to a certain
point break point and use the shell?
Indeed you can - there's an interpreter available that executes in the
context of the current stack frame when you reach a breakpoint. It's a
great way to find out what's going on.

[But don't I remember that IDLE can do that too? ...]

regards
Steve
 
S

Steve Holden

Richie said:
[Ashot]
I have been frustrated for quite some time with a lack of a history
command in IDLE


To recall a line from your history in IDLE, cursor up to that line and hit
Enter.
The history is required to be available in a chunk, to copy and paste
into a file.
To recall a line from your history in PyCrust, press Ctrl+UpArrow.
Ditto

regards
Steve
 
K

Kartic

Ashot said the following on 2/2/2005 9:45 PM:

Vim related:
----------------------
Ideally, it would be nice to have a command mapped to a keystroke that
can append the last executed command to a file. Even better would be a
system that would integrate the file editing and interactive command
line tool more seamlessly. Something along the lines of a debugger +
file editor + command line utility, where file editor = vim. I know
that vim has a utility for running python commands from its command
prompt, but I have had a hard time getting this to work in windows and
haven't explored it. Has anyone seen/tried a system along these lines,
perhaps incorporating the python debugger (pdb)? I can see something
that will run the file you are editing in vim up to the cursor or a
mark with a set_trace at the line you are editing.


I am VIM guy too but I have not got to the point of writing a VIM macro
to execute a selection.

VIM on UNIXish OSes can be built with the Python interpreter (so using
:python <expr or exec string> will execute it). AFAIK, Vim on Windows is
able to execute Python using the :python notation; I guess it uses the
Python installation. I actually did not have to do anything other than
install GVim; it just works on windows with :python.

Try :help python in Vim to read the relevant help entries.

I was considering writing a macro, map it to a keystroke for one to
execute a selected code block in VIM but have not yet got around to
doing it. May be one of these days..sigh...

This probably does not help you very much but there is hope :)

Like Fuzzyman said you can set the EDITOR environment variable and use
IPython. The magic %edit <slice notation from history or no arguments>
will fire up your editor and the script will be saved to a temp file.
Though I am not entirely happy with that feature (may be something that
I am missing) but I live it. So if you set EDITOR as gvim.exe in
Windows, IPython fires up Gvim instead of the default notepad (yuck!).

In IPython, you can type pdb at the prompt and it toggles the debugger
state. So if your program raises an error, IPython starts pdb if debug
is on. IPython is nifty but I am just getting a feel for it.

Thanks,
-Kartic
 
R

Richie Hindle

[Steve]
The history is required to be available in a chunk, to copy and paste
into a file.

I see, sorry, I didn't catch that the first time round.

(In PyCrust you can use Alt+LeftDrag to copy a rectangular selection -
you'll still need to remove any output, but at least you can get rid of
the >>> prompts in one go.)
 
M

Markus Wankus

I highly recommend trying pyDev. 0.9 just came out, and I find 0.85
very usable and quite cool. There is nice debug support, and
context-sensitive code completion as well as real-time validation of
your code. This is an exciting project with a bright future in my opinion.

Markus.
 
C

Christos TZOTZIOY Georgiou

I have been frustrated for quite some time with a lack of a history
command in IDLE (in fact with IDLE in general). Often I'll develop new
code at the command line, testing each line as I go. Currently I have to
copy and paste, removing outputs and the ">>>" at each line.
Is it perhaps possible to make some kind of hack to do this (dump a
command history)?

I am not quite sure if it's exactly what you need, but, apart from moving to
previous lines and pressing Enter, do you know about Alt-P and Alt-N?
 
T

Tim Hoffman

Have a gander at Boa Constructor.

YOu can certainly go to a shell when debugging. (ie set breakpoint)
then the shell is attached to that context.

T
 
P

Pat

Ashot said:
This is sort of both Python and Vim related (which is why I've posted to
both newsgroups).

Python related:
----------------------
I have been frustrated for quite some time with a lack of a history
command in IDLE (in fact with IDLE in general). Often I'll develop new
code at the command line, testing each line as I go. Currently I have to
copy and paste, removing outputs and the ">>>" at each line.
Is it perhaps possible to make some kind of hack to do this (dump a
command history)?

Idle in general isn't that great IMO, so I was wondering also if there are
better alternatives out there? What do people use mostly? I've tried
something called pyCrust, but this too didn't have history and some other
things I was looking for.

PyCrust is only a shell, not a full-blown IDE, so it likely lacks
things that you were looking for. But it certainly does have history,
multi-line command recall, and cut/paste options with and without the
leading prompts. In fact, the default Copy command (Ctrl+C) strips out
the prompts, and the Copy Plus command (Shift+Ctrl+C) retains the
prompts. If you select the Session tab you'll see the entire command
history, without prompts and without the responses from the Python
interpreter. Here are some other keybindings:

* Key bindings:
Home Go to the beginning of the command or line.
Shift+Home Select to the beginning of the command or line.
Shift+End Select to the end of the line.
End Go to the end of the line.
Ctrl+C Copy selected text, removing prompts.
Ctrl+Shift+C Copy selected text, retaining prompts.
Ctrl+X Cut selected text.
Ctrl+V Paste from clipboard.
Ctrl+Shift+V Paste and run multiple commands from clipboard.
Ctrl+Up Arrow Retrieve Previous History item.
Alt+P Retrieve Previous History item.
Ctrl+Down Arrow Retrieve Next History item.
Alt+N Retrieve Next History item.
Shift+Up Arrow Insert Previous History item.
Shift+Down Arrow Insert Next History item.
F8 Command-completion of History item.
(Type a few characters of a previous command and
press F8.)
Ctrl+Enter Insert new line into multiline command.
Ctrl+] Increase font size.
Ctrl+[ Decrease font size.
Ctrl+= Default font size.
Hope that helps.

Pat
 
F

Fernando Perez

Hi,
This is sort of both Python and Vim related (which is why I've posted to
both newsgroups).

[...]

I know you've been using ipython recently (the readline color bugs), so perhaps
my reply is a bit redundant. Forgive me if that's the case, I just want to
give you some useful info.

Just in case you haven't come across these features (the manual is kind of long
and dry), I should note that ipython has pretty much everything you've asked
for here. %hist -n dumps your history without line numbers (for copy/paste),
%logstart gives you an incremental log (valid python code) of your current
session, %save allows you to save a selected group of lines to a file, and
%edit will open up $EDITOR (or vi in Unix by default) at the source of any
accessible object. With %pdb, you can even trigger automatically pdb at any
uncaught exception (in Emacs, you'll even get the source simultaneously opened,
I'm sure something similar could be done for vi).

Ipython is not an IDE, but it does offer an extensible command-line environment
which tries hard to be very efficient. Hopefully this year I'll be able to
work on integrating it (optionally, since it will never lose its command-line
functionality) with GUIs as well.

Regards,

f
 
A

Ashot

Hi,
This is sort of both Python and Vim related (which is why I've posted to
both newsgroups).

[...]

I know you've been using ipython recently (the readline color bugs), so perhaps
my reply is a bit redundant. Forgive me if that's the case, I just want to
give you some useful info.

Just in case you haven't come across these features (the manual is kind of long
and dry), I should note that ipython has pretty much everything you've asked
for here. %hist -n dumps your history without line numbers (for copy/paste),
%logstart gives you an incremental log (valid python code) of your current
session, %save allows you to save a selected group of lines to a file, and
%edit will open up $EDITOR (or vi in Unix by default) at the source of any
accessible object. With %pdb, you can even trigger automatically pdb at any
uncaught exception (in Emacs, you'll even get the source simultaneously opened,
I'm sure something similar could be done for vi).

yup, this is why I've been using it, its (almost exactly :) what I was looking for. I had tried it before, but was reluctant to use it because the windows terminal is not very appealing.
Some things I've noticed so far that I think could be improved, some of which are minor but annoying:

edit doesn't work with classes even though it says it should, you have to point it to a function in the class (perhaps only in windows)

under windows vim/gvim doesn't jump to the line of the function.. you said that this should work in vi, but I'm guessing its a Windows thing

**the biggest problem for me is edit forgets code in which there were errors. for example:"ed" type some nonsense, and ed -p doesn't remember. Thats putting an awful lot of pressure on getting the syntax right everytime =] Perhaps I am missing something here?

it would be really great if the code executed on save rather than exit, but I'm not sure if this is possible. This would be very useful for people using an editor not in the console.. that way you wouldn't have to keep opening/closing new editor windows.

this isn't a big deal, but it would be nice if there was an easy way to refer to the entire history (for edit/save/etc)

would be nice if you could send stuff to the clipboard.

There are a few other things I'm probably forgetting, but having said all that, I've come off a little negative here. I really like IPython so far, its got all the things I was looking for, thank you very much for your work. If I have the time in the future I would definately contribute to this project.

..a
Ipython is not an IDE, but it does offer an extensible command-line environment
which tries hard to be very efficient. Hopefully this year I'll be able to
work on integrating it (optionally, since it will never lose its command-line
functionality) with GUIs as well.

Regards,

f



--
==============================
Ashot Petrosian
University of Texas at Austin, Computer Sciences
(views expressed are solely my own)
==============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top