2011-06-20 13:40:28 -04:00
|
|
|
snippet #!
|
|
|
|
#!/usr/bin/env python
|
|
|
|
snippet imp
|
|
|
|
import ${1:module}
|
|
|
|
# Module Docstring
|
|
|
|
snippet docs
|
|
|
|
'''
|
|
|
|
File: ${1:`Filename('$1.py', 'foo.py')`}
|
|
|
|
Author: ${2:`g:snips_author`}
|
|
|
|
Description: ${3}
|
|
|
|
'''
|
|
|
|
snippet wh
|
|
|
|
while ${1:condition}:
|
|
|
|
${2:# code...}
|
|
|
|
# dowh - does the same as do...while in other languages
|
|
|
|
snippet dowh
|
|
|
|
while True:
|
|
|
|
${1:# code...}
|
|
|
|
if ${2:condition}:
|
|
|
|
break
|
|
|
|
snippet with
|
|
|
|
with ${1:expr} as ${2:var}:
|
|
|
|
${3:# code...}
|
|
|
|
snippet for
|
|
|
|
for ${1:needle} in ${2:haystack}:
|
|
|
|
${3:# code...}
|
|
|
|
# New Class
|
|
|
|
snippet cl
|
|
|
|
class ${1:ClassName}(${2:object}):
|
|
|
|
"""${3:docstring for $1}"""
|
|
|
|
def __init__(self, ${4:arg}):
|
|
|
|
${5:super($1, self).__init__()}
|
|
|
|
self.$4 = $4
|
|
|
|
${6}
|
|
|
|
# New Function
|
|
|
|
snippet def
|
2011-06-20 00:10:55 -04:00
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):#{{{
|
2011-06-20 13:40:28 -04:00
|
|
|
"""${3:docstring for $1}"""
|
|
|
|
${4:pass}
|
2011-06-20 00:10:55 -04:00
|
|
|
#}}}
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet deff
|
2011-06-20 00:10:55 -04:00
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): #{{{
|
2011-06-20 13:40:28 -04:00
|
|
|
${3}
|
2011-06-20 00:10:55 -04:00
|
|
|
#}}}
|
2011-06-20 13:40:28 -04:00
|
|
|
# New Method
|
|
|
|
snippet defs
|
2011-06-20 00:10:55 -04:00
|
|
|
def ${1:mname}(self, ${2:arg}):#{{{
|
2011-06-20 13:40:28 -04:00
|
|
|
${3:pass}
|
2011-06-20 00:10:55 -04:00
|
|
|
#}}}
|
2011-06-20 13:40:28 -04:00
|
|
|
# New Property
|
|
|
|
snippet property
|
|
|
|
def ${1:foo}():
|
|
|
|
doc = "${2:The $1 property.}"
|
|
|
|
def fget(self):
|
|
|
|
${3:return self._$1}
|
|
|
|
def fset(self, value):
|
|
|
|
${4:self._$1 = value}
|
|
|
|
# Lambda
|
|
|
|
snippet ld
|
|
|
|
${1:var} = lambda ${2:vars} : ${3:action}
|
|
|
|
snippet .
|
|
|
|
self.
|
|
|
|
snippet try Try/Except
|
|
|
|
try:
|
|
|
|
${1:pass}
|
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
snippet try Try/Except/Else
|
|
|
|
try:
|
|
|
|
${1:pass}
|
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
else:
|
|
|
|
${5:pass}
|
|
|
|
snippet try Try/Except/Finally
|
|
|
|
try:
|
|
|
|
${1:pass}
|
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
finally:
|
|
|
|
${5:pass}
|
|
|
|
snippet try Try/Except/Else/Finally
|
|
|
|
try:
|
|
|
|
${1:pass}
|
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
else:
|
|
|
|
${5:pass}
|
|
|
|
finally:
|
|
|
|
${6:pass}
|
|
|
|
# if __name__ == '__main__':
|
|
|
|
snippet ifmain
|
|
|
|
if __name__ == '__main__':
|
|
|
|
${1:main()}
|
|
|
|
# __magic__
|
|
|
|
snippet _
|
|
|
|
__${1:init}__${2}
|
|
|
|
# python debugger (pdb)
|
|
|
|
snippet pdb
|
|
|
|
import pdb; pdb.set_trace()
|
|
|
|
# ipython debugger (ipdb)
|
|
|
|
snippet ipdb
|
|
|
|
import ipdb; ipdb.set_trace()
|
|
|
|
# ipython debugger (pdbbb)
|
|
|
|
snippet pdbbb
|
|
|
|
import pdbpp; pdbpp.set_trace()
|
|
|
|
# GPL
|
|
|
|
snippet gpl
|
|
|
|
# ${1:Name}
|
|
|
|
# Copyright (C) `strftime("%Y")` ${2:Author}
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
${3:#code}
|