]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/snippets/python.snippets
Add Rust tools to vim
[rbdr/dotfiles] / vim / snippets / python.snippets
1 snippet #!
2 #!/usr/bin/env python
3
4 snippet imp
5 import ${1:module}
6 # Module Docstring
7 snippet docs
8 '''
9 File: ${1:`Filename('$1.py', 'foo.py')`}
10 Author: ${2:`g:snips_author`}
11 Description: ${3}
12 '''
13 snippet wh
14 while ${1:condition}:
15 ${2:# code...}
16 snippet for
17 for ${1:needle} in ${2:haystack}:
18 ${3:# code...}
19 # New Class
20 snippet 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
28 snippet def
29 def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
30 """${3:docstring for $1}"""
31 ${4:pass}
32 snippet deff
33 def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
34 ${3}
35 # New Method
36 snippet defs
37 def ${1:mname}(self, ${2:arg}):
38 ${3:pass}
39 # New Property
40 snippet 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
48 snippet ld
49 ${1:var} = lambda ${2:vars} : ${3:action}
50 snippet .
51 self.
52 snippet try Try/Except
53 try:
54 ${1:pass}
55 except ${2:Exception}, ${3:e}:
56 ${4:raise $3}
57 snippet try Try/Except/Else
58 try:
59 ${1:pass}
60 except ${2:Exception}, ${3:e}:
61 ${4:raise $3}
62 else:
63 ${5:pass}
64 snippet try Try/Except/Finally
65 try:
66 ${1:pass}
67 except ${2:Exception}, ${3:e}:
68 ${4:raise $3}
69 finally:
70 ${5:pass}
71 snippet 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__':
81 snippet ifmain
82 if __name__ == '__main__':
83 ${1:main()}
84 # __magic__
85 snippet _
86 __${1:init}__${2}