tags:

views:

150

answers:

9

I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it.

I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS.

From my experience with R (working with excellent Notepad++ and NppToR combo) I usually try to work with my scripts line by line (or region by region) in order to understand what each step of my script is doing.. and to check results on the fly.

My question: is there and IDE (or editor?) for Windows that lets you evaluate single line of Python script?

I have seen quite a lot of discussion regarding IDEs in Python context.. but havent stubled upon this specific question so far.

Thanks for help!

+6  A: 

It's not an IDE, but you can use pdb to debug and step through your Python code. I know Emacs has built in support for it, but not so much about other editors (or IDEs) that will run in Windows.

Nathon
Thanks Nathon. I've heard lots of good comments about Emacs already. Especially that it offers very good support for R as well. Will have to try it I guess.
radek
+6  A: 

The only one I've had success with is Eclipse with Pydev

phasetwenty
Eclipse with PyDev is a great choice. Stepping through code, in and out of function calls, around loops, etc is easily accomplished via break points when run in debug mode. It also includes code completion, import support, syntax analysis, and other great features. I used the combination on multiple Linux Distributions as well as Windows 32 and 64 bit without difficulty.
g.d.d.c
Thanks phasetwenty. PyDev seems to often come on top [http://stackoverflow.com/questions/81584/what-ide-to-use-for-python]. Might be time to give it a spin.
radek
+1  A: 

PyCharm from JetBrains has a very nice debugger that you can step through code with.

Django and console integration built in.

duffymo
+2  A: 

WingIDE, I've been using it successfully for over a year, and very pleased with it.

David V
+2  A: 

If you are on Windows, give Pyscripter a try -- it offers comprehensive, step-through debugging, which will let you examine the state of your variables at each step of your code.

Sean Vieira
A: 

The Pythonwin IDE has a built-in debugger at lets you step through your code, inspect variables, etc.

http://starship.python.net/crew/mhammond/win32/Downloads.html

http://sourceforge.net/projects/pywin32/

The package also includes a bunch of other utility classes and modules that are very useful when writing Python code for Windows (interfacing with COM, etc.).

It's also discussed in the O'Reilly book Python Programming On Win32 by Mark Hammond.

bgporter
+1  A: 

Take the hint: The basic Python Read-Execute-Print-Loop (REPL) must work.

Want Evidence?

Here it is: The IDE's don't offer much of an alternative. If REPL wasn't effective, there's be lots of very cool alternatives. Since REPL is so effective, there are few alternatives.

Note that languages like Java must have a step-by-step debugger because there's no REPL.

Here's the other hint.

If you design your code well, you can import your libraries of functions and classes and exercise them in REPL model. Many, many Python packages are documented by exercising the package at the REPL level and copying the interactions.

The Django documentation -- as one example -- has a lot of interactive sessions that demonstrate how the parts work together at the REPL prompt.

This isn't very GUI. There's little pointing and clicking. But it seems to be effective.

S.Lott
+1  A: 

If you like R's layout. I highly recommend trying out Spyder. If you are using windows, try out Python(x,y). It is a package with a few different editors and a lot of common extra modules like scipy and numpy.

l337x911
Bingo. From what I tried so far Spyder looks brilliant. Ctrl + F9 executes selection of the code. And Python(x,y) bundle comes with all other goodies to start learning about, including Eclipse, also recommended by others. Thanks!
radek
+1  A: 

I use Notepad++ for most of my Windows based Python development and for debugging I use Winpdb. It's a cross platform GUI based debugger. You can actually setup a keyboard shortcut in Notepad++ to launch the debugger on your current script:

To do this go to "Run" -> "Run ..." in the menu and enter the following, making sure the path points to your winpdb_.pyw file:

C:\python26\Scripts\winpdb_.pyw "$(FULL_CURRENT_PATH)"

Then choose "Save..." and pick a shortcut that you wish to use to launch the debugger.

PS: You can also setup a shortcut to execute your python scripts similarly using this string instead:

C:\python26\python.exe "$(FULL_CURRENT_PATH)"
offsound
Thanks offsound. Notepad++ is usually my first choice as well. Especially that you can nicely tie it to R and Stata, where I work most of the time. Basic Python editing is easy there as well. Haven't heard about Winpdb tho. Will have to check it.
radek