]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/snippets/python.snippets
Update vim plugins
[rbdr/dotfiles] / vim / snippets / python.snippets
... / ...
CommitLineData
1snippet #!
2 #!/usr/bin/env python
3
4snippet imp
5 import ${1:module}
6# Module Docstring
7snippet docs
8 '''
9 File: ${1:`Filename('$1.py', 'foo.py')`}
10 Author: ${2:`g:snips_author`}
11 Description: ${3}
12 '''
13snippet wh
14 while ${1:condition}:
15 ${2:# code...}
16snippet for
17 for ${1:needle} in ${2:haystack}:
18 ${3:# code...}
19# New Class
20snippet cl
21 class ${1:ClassName}(${2:object}):
22 """${3:docstring for $1}"""
23 def __init__(self, ${4:arg}):
24 ${5:super($1, self).__init__()}
25 self.$4 = $4
26 ${6}
27# New Function
28snippet def
29 def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
30 """${3:docstring for $1}"""
31 ${4:pass}
32snippet deff
33 def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
34 ${3}
35# New Method
36snippet defs
37 def ${1:mname}(self, ${2:arg}):
38 ${3:pass}
39# New Property
40snippet property
41 def ${1:foo}():
42 doc = "${2:The $1 property.}"
43 def fget(self):
44 ${3:return self._$1}
45 def fset(self, value):
46 ${4:self._$1 = value}
47# Lambda
48snippet ld
49 ${1:var} = lambda ${2:vars} : ${3:action}
50snippet .
51 self.
52snippet try Try/Except
53 try:
54 ${1:pass}
55 except ${2:Exception}, ${3:e}:
56 ${4:raise $3}
57snippet try Try/Except/Else
58 try:
59 ${1:pass}
60 except ${2:Exception}, ${3:e}:
61 ${4:raise $3}
62 else:
63 ${5:pass}
64snippet try Try/Except/Finally
65 try:
66 ${1:pass}
67 except ${2:Exception}, ${3:e}:
68 ${4:raise $3}
69 finally:
70 ${5:pass}
71snippet try Try/Except/Else/Finally
72 try:
73 ${1:pass}
74 except ${2:Exception}, ${3:e}:
75 ${4:raise $3}
76 else:
77 ${5:pass}
78 finally:
79 ${6:pass}
80# if __name__ == '__main__':
81snippet ifmain
82 if __name__ == '__main__':
83 ${1:main()}
84# __magic__
85snippet _
86 __${1:init}__${2}