Author: Ram Rachum

Description: 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.

URL: https://github.com/cool-RR/cute-wing-stuff

ArgToAttr (last edited 2011-02-04 21:24:25 by RamRachum)

Disclaimer: This wiki is maintained by a community of volunteers. Wingware makes no warranty for the accuracy, fitness for a purpose, or safety of any code or information provided on this site. Please report abuse to support at wingware dot com.