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.
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:
Configuring the Python Path
Auto-completion and many of Wing's other features rely on the IDE's analysis of your source code and the code that you import. If Wing cannot find some of the imported modules, it cannot offer editing assistance for them. Often this just works, but in some cases you may need add to the Python Path in Wing's Project Properties, accessed from the Project menu.
Notice that the auto-completer contains two columns of icons like and that indicate the origin and type of the symbol. These are described in detail in the Auto-Completer documentation.
The completer also offers code snippets appropriate for the current context. These are indicated with the 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 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 firstname.lastname@example.org.
Share this article: