A blog about the development and usage of GarlicSim, the open-source Pythonic framework for computer simulations.
Written by Ram Rachum, developer of GarlicSim.

GarlicSim Website

Twitter

GitHub Repository

Ram's Personal Website

17th January 2011

Text

Releasing my Wing IDE scripts

I love Wing IDE. But then again… I’m often annoyed by many of its less-than-brilliant parts; Wing’s shell tool is pretty mediocre, and in general Wing has various annoying bugs, in such areas as workspace management or nose integration, just to name a couple.

But I still love Wing IDE. Wing and me are like an old married couple. Sometimes I take Wing for granted because I’ve gotten used to how awesome it is. I remember how happy I was when I originally switched to Wing after leaving my overly-promiscuous ex-girlfriend, PyDev. She had good things going for her, but she didn’t seem to have gotten over her ex, Java. And she was a bit of a heavyweight.

With your permission I’ll drop the metaphors for the remainder of this post.

So Wing has a few weak points, but it’s still one of the best Python IDEs out there, quite possibly the best. I did try PyCharm after I’ve seen so many cool Pythonistas recommending it, but I found it really lacking. The strength of an IDE is in the details; there are a huge number of small but important behaviors that an IDE needs to get right in order to be considered a good IDE, and the Wingware crew seem to have gotten most of these things figured out in their over 10 years of work on Wing IDE. When I tried one of PyCharm’s release candidates three months ago, it didn’t even support dragging and dropping Python files into the IDE for editing. (I’m sure that PyCharm has some advantages over Wing, I just personally like my IDE to be an extensively battle-tested piece of software.)

In conclusion: I love Wing IDE and I recommend anyone doing Python development to at least give it a try.

My Wing IDE scripts

Today I’m releasing my Wing IDE scripts. These are a few helpful scripts that save me some typing in my everyday work with Wing.

Here is the GitHub repo with installation instructions.

Note that all of the scripts are intended for Wing 4; I haven’t tested them on Wing 3.

arg-to-attr

Turn an argument to __init__ into an instance attribute.

For example, you have just typed this:

class MyObject(object):
    def __init__(self, crunchiness):
        <Cursor is here>

(Of course, you can substitute crunchiness for whatever your argument’s name is.)

Now, you might want to put a self.crunchiness = crunchiness line in that __init__ method. But that would take so much typing, because self.crunchiness doesn’t exist yet, and won’t be autocompleted. That would require you to make around 20 keystrokes. I don’t know about you, but I’m just not ready for that kind of a commitment.

Instead, type crunchiness. (You’ll get autocompletion because it exists as an argument.) Then run this arg-to-attr script.

The final result is that you’ll get a self.crunchiness = crunchiness line and have the cursor ready in the next line.

Suggested key combination: Alt-Insert A.

flip-case

Flip the case of the current word between undercase and camelcase.

For example, if the cursor is on something_like_this and you activate this script, you’ll get SomethingLikeThis. Do it again and you’ll get something_like_this again.

Suggested key combination: Alt-Insert C.

comment-braces

Create “comment braces” with a title around a piece of code.

For example, if you have this code:

do_something()
do_something_else()
meow = frr + 7
do_something_again()

You can select it, then run the comment-braces script with a title of ”doing inane stuff”, to get this:

### Doing inane stuff: ################################################
#                                                                     #
do_something()
do_something_else()
meow = frr + 7
do_something_again()
#                                                                     #
### Finished doing inane stuff. #######################################

(Don’t try this inside a docstring, it works only in real code.)

The title usually has a first word ending with “ing”. Don’t bother capitalizing the first letter or ending the sentence with any punctuation mark. You may also use an empty title to get a title-less comment line.

Suggested key combination: Alt-Insert B.

comment-hr

Enter a horizontal line of “#” characters going until character 79.

Example:

#######################################################################

Suggested key combination: Alt-Insert H.

Feedback

I’ll be happy to get comments, opinions, code reviews and patches to the above scripts!

Comments
All content in this website is copyright © 1986-2011 Ram Rachum.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License, with attribution to "Ram Rachum at ram.rachum.com" including link to ram.rachum.com.
To view a copy of this license, visit: http://creativecommons.org/licenses/by-sa/3.0/