Mar 20, 2015

Wing IDE Pro's debugger makes is easier to work interactively with Python. In addition to debugging, it is also a great way to navigate and understand unfamiliar code, and to write new code interactively in the live runtime state for which the code is being designed.

Starting with Wing 5.1, multiple debug connections can be made at once, so it is much easier to write and debug multi-process code.

Multi-Process Debugging

Wing 5.1 adds a process selector wherever a stack selector is shown in the user interface, in addition to a thread selector if there are multiple threads in the debug process. The process selector groups processes into a process tree, showing the relationship between them regardless of how they were created or debug-enabled.

Process Selector

When multiple processes are being debugging, pressing the Alt key causes the Debug/Continue, Stop, Restart, and Pause toolbar icons to apply that operation to all the active processes:

/images/blog/multiprocess-debug/toolbar.png

These operations are also in the Debug > Processes menu, along with commands for starting additional new debug processes from the IDE.

Options to control multi-process debugging are in the Debugger > Processes preferences group. For example, you can control when Wing switches to a newly attached debug process and which processes to kill when killing a single debug process.

Multi-Process Debug Preferences

Automatically Debugging Child Processes

Optionally, you can also automatically debug-enable sub-processes created with multiprocessing, via sys.executable, and (on Posix) with os.fork().

Automatically debugging child processes is off by default since it can be confusing or unwanted in some code bases. It can be enabled with the Debugger > Processes > Debug Child Processes preference or (preferably, in most cases) on a project-by-project basis with the Debug/Execute > Debug Child Properties setting in Project Properties.

Enabling Child Process Debugging

This option is useful when working with auto-reloading web application frameworks like Flask or Google App Engine, because Wing will automatically debug the reloaded server processes.

Manually Debugging Child Processes

There are cases where sub- processes cannot be automatically debugged, such as when os.exec() is used (on Posix) or if the process is started without referencing sys.executable. In these cases, the process can still be debugged by importing wingdbstub, which is a module provided by Wing IDE to initiate debugging from outside of the IDE.

In these cases, you will need to enable Accept Debug Connections by clicking on the bug icon in the lower left of Wing's window. This causes Wing to use a fixed port for accepting debug connections. The default matches the port configured wingdbstub.py in your Wing IDE installation.

Details on doing this are in Debugging Externally Launched Code in Wing's reference manual.

Resources

More information can be found in Multi-Process Debugging in the Wing IDE manual.

A quick introduction to Wing IDE's features can be found in our Feature Overview Screencast.

Or just download Wing IDE and give it a try. The Tutorial in Wing's Help menu is a great way to get started.

Share this article:






Mar 11, 2015

Wing IDE Pro's debugger makes is easier to work interactively with Python. In addition to debugging, it is also a great way to navigate and understand unfamiliar code, and to write new code interactively in the live runtime state for which the code is being designed.

A great little feature in Wing's debugger is the ability to move the program counter back to code you have already executed. This way, if you debug too far you can go back without having to restart your debug process.

This is done by right-clicking on the line where you want to move the program counter and selecting Move Program Counter Here:

Move Program Counter

That's all there is to it!

Move Program Counter Result

Note that due to the way Python is implemented, the program counter can only be moved within the current bottom-most stack frame.

To try this out, download Wing now!

Share this article:






Sep 12, 2014

An often-requested feature that we've added to Wing IDE version 5.0.9 is the ability to mark a range of code in the editor as "active" so it is easily reevaluated in the Python Shell or Debug Probe. This makes it easier to work interactively with Python without having to copy and paste code between the Python Shell or Debug Probe and the editor.

To use this feature, select a range of code in the editor and press the Set Active Range icon setactiverange in the top right of the Python Shell or Debug Probe. This marks the range in the editor and adds an Evaluate Active Range icon evaluate-active-range for evaluating the range and a Visit Active Range icon visit-active-range for visiting the active range in the editor to the top right of the shell tool. The Remove Active Range remove-active-range icon can be used to remove the active range.

Here is an example of this feature in action, in the integrated Python Shell:



The same capability exists in the Debug Probe, which is a Python Shell that acts in the context of the currently active debug stack frame.

Setting up Key Bindings

There are no default key bindings for these actions, but keys can be bound to them using the User Interface > Keyboard > Custom Key Bindings preference. The commands defined are:

python-shell-toggle-active-range sets or clears the active range in the Python Shell, using the current selection or current line in the editor when setting the range.

python-shell-evaluate-active-range evaluates the current active range in the Python Shell.

python-shell-show-active-range shows the Python Shell's active range in the editor.

Similar commands are defined for the Debug Probe: debug-probe-toggle-active-range, debug-probe-evaluate-active-range, and debug-probe-show-active-range.

Share this article:






Jun 24, 2014

Check out our new screencast, which shows some of the features of Wing IDE Professional version 5 in action:



Share this article:






May 23, 2014

In the previous blog post we talked about how auto-editing in Wing IDE Pro can be used to speed up writing and editing Python code. Now let's look at how the auto-completer works with other parts of the IDE to make coding easier.

Auto-completer Basics

By default, Wing's auto-completer uses the Tab key for completion, but this can be changed with the Editor > Auto-Completion > Completion Keys preference. The same preferences group lets you specify whether to show the completer immediately or only after a certain number of characters or time, how to place the completion, and various other options.

Here is what the completer looks like in action:



Notice that the auto-completer contains two columns of icons like keyword module inherited method and dict that indicate the origin and type of the symbol. These are described in detail in the Auto-Completer documentation.

Snippets

The completer also offers code snippets appropriate for the current context. These are indicated with the snippet icon. The default set of snippets that come with Wing IDE may be viewed and altered in the Snippets tool in the Tools menu.

Here is an example of entering snippets with the auto-completer, showing how the same snippet may enter different code, according to context:



Editing with the Debugger

Normally, Wing's auto-completer shows type information obtained through static analysis of your code and the libraries that you import. This works well in most cases, but may fail in dynamic code that resists static analysis.

A quick and easy way to get around this is to set a breakpoint in the code you are working on and start the debugger to reach that breakpoint. Once this is done, the auto-completer uses both static analysis and runtime type analysis in any code that is active on the debug process stack. The source of a symbol in the completer is indicated with the runtime icon.

Starting the debugger is usually just a question of selecting Start/Continue in the Debug menu or using the toolbar icon. In some cases you may first need to set up and configure a project.

Here is an example of this:



Working while the debugger is active also lets you try out new code right away. We'll talk more about that in the next blog post.

Turbo Completion Mode

Wing's auto-completer offers another completion mode for Python that can be incredibly productive, particularly when working with the live runtime state, as described above. It turns all non-symbol keys into completion keys in a context-appropriate way, according to where you are typing, what you are typing, and what key you have just pressed.

So, for example, pressing the = key after an argument completes the argument but pressing the = key after for x does not because you are defining a new symbol x.

Turbo-completion is illustrated in the following:



This mode is off by default because it requires some getting used to. But it is well worth learning and can be enabled with the Edit > Auto-completion > Python Turbo Mode preference.

Using the Source Assistant

The Source Assistant is where Wing shows more details about the type of a symbol, including documentation, call signature, and information about object inheritance and overridden methods. For builtin types and the standard library, this includes also links into Python documentation.

The Source Assistant is integrated with every part of Wing IDE, so it shows information for the current selection in the editor, auto-completer, Python Shell, Source Browser, Project manager, and Debug Probe (a shell for interacting with the debug process that we'll talk about next time).

Here are some examples of the Source Assistant in action:



That's it for now. Next time we'll take a detailed look at Wing's debugger.

We're continuously improving Wing's auto-completer and Source Assistant. If you have features you would like to see, or have any questions about the existing features, please email us at support@wingware.com.

Share this article:




Older Articles

2014

Learn how to use Wing IDE Pro's advanced auto-editing features to speed up writing and modifying Python code.   Read more

Wingware Blog