Thursday, March 20, 2014

PyDev 3.4.1: improved interactive console, multiprocess debugging

One of the major features added is that now F2 can be used to send the current line to the interactive console (or the current multi-line selection).

It's close to what was previously used as Ctrl+Alt+Enter, but with some differences:

1. It'll fix the indentation of the code when sending things to the console (so, you shouldn't have syntax errors because of the indentation when using Ctrl+Alt+Enter).

2. When a line is sent, the cursor goes to the next line (this may seem minor, but it's a huge time-saver and makes things much smoother).

3. It's a single keypress! (and that was really hard to decide as all keys seem to be taken -- even F2 -- but I think that F2 as it was before wasn't very useful).

All in all, if you're into doing things interactively, things are nicer with F2.

Note: Ctrl+Alt+Enter can still be used to do an execfile, but aside from that, F2 is the preferred way to send contents to the console.

Credit goes to Ed Catmur and James Blackburn for this feature -- I just integrated it :)

Another major feature is that the debugger now works properly when debugging multiple processes (and when a launch is terminated it'll also kill all subprocesses). This means the previous patch the debugger did to Django is no longer needed... Just F11 to relaunch your last launch and debug multiple processes!

Major feature #3: Ctrl+F9 (which opens a dialog for selecting which tests to run) now works properly with py.test too -- even if tests are not under class.

Major feature #4: pxd and pxi Cython files are now properly handled.

And as the last thing, which isn't an actual feature, but something noteworthy: PyDev no longer changes the default encoding (i.e.: sys.setdefaultencoding). Back when PyDev started to do that (in Python 2.4 I believe) there wasn't much choice to see unicode contents properly in the console, so, PyDev changed the default encoding to be the encoding of the console. Fast forward a bit and Python now provides a way to set the sys.stdout/stderr encodings through PYTHONIOENCODING (Python 2.6 onwards), so, PyDev now only sets that variable and no longer changes the default encoding (the main issue there is that when some application was later deployed, it could have a different default encoding and things could break because of UnicodeDecodeErrors).

Note that this is not all, other things were done too... See: http://pydev.org/ for details -- and note that LiClipse: http://brainwy.github.io/liclipse/ is already updated to the latest PyDev too.

4 comments:

  1. Anonymous10:55 AM

    I like very much the PyDev. That's what I use to develop my Python Projects.

    This function pressing F2 is awesome, but I got the message "SyntaxError: trailing comma not allowed without surrounding parentheses" because I used F2 in a line like this:
    from Tkinter import Tk, Button, Label, \
    Listbox, Frame, LabelFrame, Menu, Scrollbar, Toplevel

    The problem is the PyDev didn't recognize "\" like a line braker.

    Don't mater, I'll enjoy the new release :-)

    ReplyDelete
  2. Hi there, can you report that in the tracker?

    https://sw-brainwy.rhcloud.com/tracker/PyDev

    Thanks.

    ReplyDelete
  3. Anonymous4:57 PM

    This is great. Is there a way to do that with the entire script without selecting the whole thing? I've tweaked my run configuration to allow for this before but can't find the link to do it again.

    Thanks!

    ReplyDelete
  4. Ctrl+Alt+Enter may still be used (it will send the entire script if you don't select anything).

    Cheers,

    Fabio

    ReplyDelete