-
Notifications
You must be signed in to change notification settings - Fork 150
Snippets
gabrielelanaro edited this page Dec 2, 2011
·
8 revisions
In this section are described the most useful emacs-for-python snippets (using the Yasnippet extension). It is possible that for the same keyword there are two available snippets, you will prompted by yasnippet when using it.
If you write some awesome and useful snippet, tell me and I will include in emacs-for-python!
- doc
-
This is used to document the code you're using, it insert the triple quotes:
"""_ """
note that if you're using cua-mode you can select a region, then type doc and the region will be wrapped with triple quotes!
- class
-
Insert the class snippet, reduced to bare-bones:
class ClassName(Base): _
- init
-
Insert the constructor method of the class:
def __init__(self, ...): _
- super
-
Automatically call the super method in this way:
class MyFrame(wx.Frame) def __init__(self, name = "MyName"): <TAB>
produces:
class MyFrame(wx.Frame) def __init__(self, name = "MyName"): super(MyFrame, self).__init__(name="MyName)_
- def
- New function definition
- defm
- New method definition, like def but with the self parameter
- testcase
- New
unittest.TestCase
class used for unittests - ifmain
-
Used at the end of file in executable scripts, I use it all the time:
if __name__ == '__main__': _
- prop
- Helper to define a new class property
- for, while, from
- The classics, they are by default included in yasnippet but I don't use them so much.