Wing Tips: Auto-Editing in Wing Pro (Part 2 of 3)

Apr 04, 2019

Wing Pro implements a suite of auto-editing operations that take care of common low-level editing tasks. Last week we looked at creating and managing blocks in Python code.

In part two of this Wing Tips series on Wing Pro's auto-editing feature we turn to auto-invocation, which makes writing Python code that calls functions and methods easier and less prone to errors.

Auto-Enter Invocation Args

When an invocation is typed in Wing Pro, for example getattr(, the editor temporarily inserts all the arguments for getattr and enters a data entry mode in which the Tab key can be used to move between the arguments and default values. When the caret moves out of the argument list, data entry mode ends and any unchanged default arguments are removed.


Shown above: Type "self.a" followed by Tab for completion, Tab five times to reach the last argument value, and then "Fa" followed by tab for completion; after leaving the invocation, unchanged default arguments are removed.

In cases like the above, where locals are named the same as the required arguments, very little extra work is needed to complete the invocation. In other cases, you may just want to overtype what Wing enters, which is easy to do since the all the arguments are initially selected.

Configuring Python: Auto-invocation and many of Wing Pro's other features rely on the IDE's analysis of your source code and the modules that you import. This only works if Wing knows which Python you are using and where to look for modules. In most cases, setting Python Executable in Project Properties from the Project menu is all you'll need. This should be set to the value of sys.executable (after import sys) in the target Python installation. In some cases you may also need to add to Python Path in Project Properties, so all the modules you import can be found.

Auto-Entering Overridden Methods

A similar auto-editing operation enters an overridden method's arguments, when defining a method that overrides a method in an inherited class.


Shown above: Type "def G" followed by Tab for completion, and then ``:`` to move into the method body; method arguments are auto-entered based on the overridden method in class CNewsPage.

Nested Invocations

Nested invocations are also supported, for cases where another invocation is made within an outer invocation.


Shown above: Type "d = join(" to start invocation, press Tab to move to first argument, enter "convert(" to start recursive invocation, enter arguments for "convert" by tabbing between them, Tab to return to and complete invocation of "join".

That's it for now. In the next and last part of this 3-part Wing Tips series on Wing Pro's auto-editing features we'll be looking at auto-spacing, PEP 8, and a few other operations.

Share this article: