2011-06-20 13:40:28 -04:00
|
|
|
snippet #!
|
|
|
|
#!/usr/bin/env python
|
|
|
|
snippet imp
|
|
|
|
import ${1:module}
|
2013-06-26 05:42:22 -04:00
|
|
|
snippet uni
|
|
|
|
def __unicode__(self):
|
|
|
|
${1:representation}
|
2011-10-19 17:56:00 -04:00
|
|
|
snippet from
|
|
|
|
from ${1:package} import ${2:module}
|
2011-06-20 13:40:28 -04:00
|
|
|
# Module Docstring
|
|
|
|
snippet docs
|
2013-03-30 11:08:09 -04:00
|
|
|
"""
|
2013-07-07 21:41:11 -04:00
|
|
|
File: ${1:`vim_snippets#Filename('$1.py', 'foo.py')`}
|
2013-03-30 11:08:09 -04:00
|
|
|
Author: `g:snips_author`
|
|
|
|
Email: `g:snips_email`
|
|
|
|
Github: `g:snips_github`
|
|
|
|
Description: ${2}
|
|
|
|
"""
|
2013-06-26 05:42:22 -04:00
|
|
|
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet wh
|
|
|
|
while ${1:condition}:
|
2013-06-20 17:33:44 -04:00
|
|
|
${2}
|
2011-06-20 13:40:28 -04:00
|
|
|
# dowh - does the same as do...while in other languages
|
|
|
|
snippet dowh
|
|
|
|
while True:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-06-20 13:40:28 -04:00
|
|
|
if ${2:condition}:
|
|
|
|
break
|
|
|
|
snippet with
|
|
|
|
with ${1:expr} as ${2:var}:
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-06-20 13:40:28 -04:00
|
|
|
# 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-08-03 10:59:11 -04:00
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
2011-06-20 13:40:28 -04:00
|
|
|
"""${3:docstring for $1}"""
|
2013-06-20 17:33:44 -04:00
|
|
|
${4}
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet deff
|
2011-08-03 10:59:11 -04:00
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-06-20 13:40:28 -04:00
|
|
|
# New Method
|
|
|
|
snippet defs
|
2011-08-03 10:59:11 -04:00
|
|
|
def ${1:mname}(self, ${2:arg}):
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
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}
|
2013-01-27 14:13:33 -05:00
|
|
|
def fdel(self):
|
|
|
|
${5:del self._$1}
|
|
|
|
return locals()
|
|
|
|
$1 = property(**$1())
|
2011-07-16 11:21:36 -04:00
|
|
|
# Ifs
|
|
|
|
snippet if
|
|
|
|
if ${1:condition}:
|
2013-06-20 17:33:44 -04:00
|
|
|
${2}
|
2011-07-23 19:06:58 -04:00
|
|
|
snippet el
|
2011-07-16 11:21:36 -04:00
|
|
|
else:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-07-23 19:06:58 -04:00
|
|
|
snippet ei
|
|
|
|
elif ${1:condition}:
|
2013-06-20 17:33:44 -04:00
|
|
|
${2}
|
2011-07-16 11:21:36 -04:00
|
|
|
# For
|
|
|
|
snippet for
|
2011-12-10 14:02:31 -05:00
|
|
|
for ${1:item} in ${2:items}:
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-07-16 11:21:36 -04:00
|
|
|
# Encodes
|
2011-08-02 20:01:39 -04:00
|
|
|
snippet cutf8
|
2011-07-16 11:21:36 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
snippet clatin1
|
|
|
|
# -*- coding: latin-1 -*-
|
|
|
|
snippet cascii
|
|
|
|
# -*- coding: ascii -*-
|
2011-06-20 13:40:28 -04:00
|
|
|
# Lambda
|
2013-05-26 22:51:49 -04:00
|
|
|
snippet ld
|
2011-06-20 13:40:28 -04:00
|
|
|
${1:var} = lambda ${2:vars} : ${3:action}
|
|
|
|
snippet .
|
|
|
|
self.
|
|
|
|
snippet try Try/Except
|
|
|
|
try:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-06-20 13:40:28 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
snippet try Try/Except/Else
|
|
|
|
try:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-06-20 13:40:28 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
else:
|
2013-06-20 17:33:44 -04:00
|
|
|
${5}
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet try Try/Except/Finally
|
|
|
|
try:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-06-20 13:40:28 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
finally:
|
2013-06-20 17:33:44 -04:00
|
|
|
${5}
|
2011-06-20 13:40:28 -04:00
|
|
|
snippet try Try/Except/Else/Finally
|
|
|
|
try:
|
2013-06-20 17:33:44 -04:00
|
|
|
${1}
|
2011-06-20 13:40:28 -04:00
|
|
|
except ${2:Exception}, ${3:e}:
|
|
|
|
${4:raise $3}
|
|
|
|
else:
|
2013-06-20 17:33:44 -04:00
|
|
|
${5}
|
2011-06-20 13:40:28 -04:00
|
|
|
finally:
|
2013-06-20 17:33:44 -04:00
|
|
|
${6}
|
2011-06-20 13:40:28 -04:00
|
|
|
# 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()
|
2013-07-03 07:17:40 -04:00
|
|
|
# python console debugger (pudb)
|
|
|
|
snippet pudb
|
|
|
|
import pudb; pudb.set_trace()
|
2012-07-03 03:40:37 -04:00
|
|
|
snippet pprint
|
|
|
|
import pprint; pprint.pprint(${1})${2}
|
2011-07-07 14:41:13 -04:00
|
|
|
snippet "
|
|
|
|
"""
|
|
|
|
${1:doc}
|
|
|
|
"""
|
2011-10-31 13:01:25 -04:00
|
|
|
# test function/method
|
|
|
|
snippet test
|
|
|
|
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-10-31 13:01:25 -04:00
|
|
|
# test case
|
|
|
|
snippet testcase
|
|
|
|
class ${1:ExampleCase}(unittest.TestCase):
|
2013-06-20 17:39:31 -04:00
|
|
|
|
2011-10-31 13:01:25 -04:00
|
|
|
def test_${2:description}(self):
|
2013-06-20 17:33:44 -04:00
|
|
|
${3}
|
2011-11-24 07:38:52 -05:00
|
|
|
snippet fut
|
|
|
|
from __future__ import ${1}
|
2012-12-07 09:11:55 -05:00
|
|
|
#getopt
|
|
|
|
snippet getopt
|
|
|
|
try:
|
|
|
|
# Short option syntax: "hv:"
|
|
|
|
# Long option syntax: "help" or "verbose="
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])
|
2013-06-20 17:39:31 -04:00
|
|
|
|
2012-12-07 09:11:55 -05:00
|
|
|
except getopt.GetoptError, err:
|
|
|
|
# Print debug info
|
|
|
|
print str(err)
|
|
|
|
${3:error_action}
|
|
|
|
|
|
|
|
for option, argument in opts:
|
|
|
|
if option in ("-h", "--help"):
|
|
|
|
${4}
|
|
|
|
elif option in ("-v", "--verbose"):
|
|
|
|
verbose = argument
|
2013-05-16 23:19:50 -04:00
|
|
|
# logging
|
|
|
|
# glog = get log
|
|
|
|
snippet glog
|
|
|
|
import logging
|
2013-05-16 23:28:28 -04:00
|
|
|
logger = logging.getLogger(${1:__name__})
|
2013-05-16 23:19:50 -04:00
|
|
|
snippet le
|
|
|
|
logger.error(${1:msg})
|
2013-05-26 22:51:49 -04:00
|
|
|
# conflict with lambda=ld, therefor we change into Logger.debuG
|
|
|
|
snippet lg
|
2013-05-16 23:19:50 -04:00
|
|
|
logger.debug(${1:msg})
|
|
|
|
snippet lw
|
|
|
|
logger.warning(${1:msg})
|
|
|
|
snippet lc
|
|
|
|
logger.critical(${1:msg})
|
|
|
|
snippet li
|
|
|
|
logger.info(${1:msg})
|
2013-07-18 15:31:59 -04:00
|
|
|
snippet epydoc
|
|
|
|
"""
|
|
|
|
${1:Description}
|
|
|
|
|
|
|
|
@param ${2:param}: ${3: Description}
|
|
|
|
@type $2: ${4: Type}
|
|
|
|
|
|
|
|
@return: ${5: Description}
|
|
|
|
@rtype : ${6: Type}
|
|
|
|
|
|
|
|
@raise e: ${7: Description}
|
|
|
|
"""
|