2012-08-17 03:41:25 +00:00
|
|
|
snippet #!
|
2018-11-01 10:03:42 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet #!2
|
|
|
|
#!/usr/bin/env python2
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-12-08 13:20:04 +00:00
|
|
|
snippet #!3
|
|
|
|
#!/usr/bin/env python3
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet imp
|
2013-11-16 19:45:48 +00:00
|
|
|
import ${0:module}
|
2013-07-17 23:06:05 +00:00
|
|
|
snippet uni
|
|
|
|
def __unicode__(self):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0:representation}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet from
|
2013-11-16 19:45:48 +00:00
|
|
|
from ${1:package} import ${0:module}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# Module Docstring
|
|
|
|
snippet docs
|
2013-04-13 17:45:21 +00:00
|
|
|
"""
|
2013-07-17 23:06:05 +00:00
|
|
|
File: ${1:`vim_snippets#Filename('$1.py', 'foo.py')`}
|
2013-04-13 17:45:21 +00:00
|
|
|
Author: `g:snips_author`
|
|
|
|
Email: `g:snips_email`
|
|
|
|
Github: `g:snips_github`
|
2013-11-16 19:45:48 +00:00
|
|
|
Description: ${0}
|
2013-04-13 17:45:21 +00:00
|
|
|
"""
|
2013-07-17 23:06:05 +00:00
|
|
|
|
2019-01-08 10:11:54 +00:00
|
|
|
# Unittest skip
|
|
|
|
snippet sk "skip unittests" b
|
2019-03-08 11:04:56 +00:00
|
|
|
@unittest.skip(${1:skip_reason})
|
2019-01-08 10:11:54 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet wh
|
2022-09-20 08:08:31 +00:00
|
|
|
while $1:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# dowh - does the same as do...while in other languages
|
|
|
|
snippet dowh
|
|
|
|
while True:
|
2013-07-17 23:06:05 +00:00
|
|
|
${1}
|
2022-09-20 08:08:31 +00:00
|
|
|
if $0:
|
2012-08-17 03:41:25 +00:00
|
|
|
break
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet with
|
|
|
|
with ${1:expr} as ${2:var}:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2017-11-24 13:54:40 +00:00
|
|
|
snippet awith
|
|
|
|
async with ${1:expr} as ${2:var}:
|
|
|
|
${0:${VISUAL}}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00: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
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet cla
|
|
|
|
class ${1:class_name}:
|
|
|
|
"""${0:description}"""
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet clai
|
|
|
|
class ${1:class_name}:
|
|
|
|
"""${2:description}"""
|
|
|
|
def __init__(self, ${3:args}):
|
|
|
|
${0}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
|
|
|
# Data class
|
|
|
|
snippet dcl dataclass
|
|
|
|
@dataclass
|
|
|
|
class ${1:ClassName}:
|
|
|
|
"""${2:description}"""
|
|
|
|
${3:var_1}: ${4:int}
|
|
|
|
${5:var_2}: ${6:float} = ${7:0}
|
|
|
|
|
|
|
|
def ${8:total}(self): -> $6:
|
|
|
|
return ${0:self.$3 * self.$5}
|
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# New Function
|
|
|
|
snippet def
|
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
|
|
|
"""${3:docstring for $1}"""
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet deff
|
|
|
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2017-11-24 13:54:40 +00:00
|
|
|
snippet adef
|
|
|
|
async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
|
|
|
"""${3:docstring for $1}"""
|
|
|
|
${0}
|
|
|
|
snippet adeff
|
|
|
|
async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
|
|
|
${0}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# New Method
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet defi
|
|
|
|
def __init__(self, ${1:args}):
|
|
|
|
${0}
|
2015-07-13 10:22:46 +00:00
|
|
|
snippet defm
|
2012-08-17 03:41:25 +00:00
|
|
|
def ${1:mname}(self, ${2:arg}):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2017-11-24 13:54:40 +00:00
|
|
|
snippet adefm
|
|
|
|
async def ${1:mname}(self, ${2:arg}):
|
|
|
|
${0}
|
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# New Property
|
|
|
|
snippet property
|
2021-10-11 09:30:43 +00:00
|
|
|
@property
|
|
|
|
def ${1:foo}(self) -> ${2:type}:
|
|
|
|
"""${3:doc}"""
|
2022-08-08 13:45:56 +00:00
|
|
|
return self._$1
|
2021-10-11 09:30:43 +00:00
|
|
|
|
2022-08-08 13:45:56 +00:00
|
|
|
@$1.setter
|
|
|
|
def $1(self, value: $2):
|
|
|
|
self._$1 = value
|
2021-10-11 09:30:43 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# Ifs
|
|
|
|
snippet if
|
2022-09-20 08:08:31 +00:00
|
|
|
if $1:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet el
|
|
|
|
else:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet ei
|
2022-09-20 08:08:31 +00:00
|
|
|
elif $1:
|
2017-02-11 13:01:38 +00:00
|
|
|
${0:${VISUAL}}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
|
|
|
# Match
|
|
|
|
snippet match Structural pattern matching
|
|
|
|
match ${1:expression}:
|
|
|
|
case ${2:pattern_1}:
|
|
|
|
${3:pass}
|
|
|
|
case ${4:pattern_2}:
|
|
|
|
${5:pass}
|
|
|
|
|
|
|
|
# Match with wildcard
|
|
|
|
snippet matchw Pattern matching with wildcard
|
|
|
|
match ${1:expression}:
|
|
|
|
case ${2:pattern_1}:
|
|
|
|
${3:pass}
|
|
|
|
case _:
|
|
|
|
${0:pass}
|
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# For
|
|
|
|
snippet for
|
|
|
|
for ${1:item} in ${2:items}:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# Encodes
|
|
|
|
snippet cutf8
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
snippet clatin1
|
|
|
|
# -*- coding: latin-1 -*-
|
|
|
|
snippet cascii
|
|
|
|
# -*- coding: ascii -*-
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# Lambda
|
2013-07-17 23:06:05 +00:00
|
|
|
snippet ld
|
2013-11-16 19:45:48 +00:00
|
|
|
${1:var} = lambda ${2:vars} : ${0:action}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2017-12-13 14:05:24 +00:00
|
|
|
snippet ret
|
|
|
|
return ${0}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet .
|
|
|
|
self.
|
2020-04-26 01:56:16 +00:00
|
|
|
snippet sa self.attribute = attribute
|
|
|
|
self.${1:attribute} = $1
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet try Try/Except
|
|
|
|
try:
|
2017-02-11 13:01:38 +00:00
|
|
|
${1:${VISUAL}}
|
|
|
|
except ${2:Exception} as ${3:e}:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0:raise $3}
|
2018-03-31 14:56:26 +00:00
|
|
|
snippet trye Try/Except/Else
|
2012-08-17 03:41:25 +00:00
|
|
|
try:
|
2017-02-11 13:01:38 +00:00
|
|
|
${1:${VISUAL}}
|
|
|
|
except ${2:Exception} as ${3:e}:
|
2012-08-17 03:41:25 +00:00
|
|
|
${4:raise $3}
|
|
|
|
else:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-03-31 14:56:26 +00:00
|
|
|
snippet tryf Try/Except/Finally
|
2012-08-17 03:41:25 +00:00
|
|
|
try:
|
2017-02-11 13:01:38 +00:00
|
|
|
${1:${VISUAL}}
|
|
|
|
except ${2:Exception} as ${3:e}:
|
2012-08-17 03:41:25 +00:00
|
|
|
${4:raise $3}
|
|
|
|
finally:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2018-03-31 14:56:26 +00:00
|
|
|
snippet tryef Try/Except/Else/Finally
|
2012-08-17 03:41:25 +00:00
|
|
|
try:
|
2017-02-11 13:01:38 +00:00
|
|
|
${1:${VISUAL}}
|
|
|
|
except ${2:Exception} as ${3:e}:
|
2012-08-17 03:41:25 +00:00
|
|
|
${4:raise $3}
|
|
|
|
else:
|
2013-07-17 23:06:05 +00:00
|
|
|
${5}
|
2012-08-17 03:41:25 +00:00
|
|
|
finally:
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
# if __name__ == '__main__':
|
|
|
|
snippet ifmain
|
|
|
|
if __name__ == '__main__':
|
2013-11-16 19:45:48 +00:00
|
|
|
${0:main()}
|
2012-08-17 03:41:25 +00:00
|
|
|
# __magic__
|
|
|
|
snippet _
|
2013-11-16 19:45:48 +00:00
|
|
|
__${1:init}__
|
2022-08-08 13:45:56 +00:00
|
|
|
|
|
|
|
# debugger breakpoint
|
|
|
|
snippet br
|
|
|
|
breakpoint()
|
2012-08-17 03:41:25 +00:00
|
|
|
# python debugger (pdb)
|
|
|
|
snippet pdb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('pdb').set_trace()
|
2016-02-20 13:13:10 +00:00
|
|
|
# bpython debugger (bpdb)
|
|
|
|
snippet bpdb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('bpdb').set_trace()
|
2012-08-17 03:41:25 +00:00
|
|
|
# ipython debugger (ipdb)
|
|
|
|
snippet ipdb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('ipdb').set_trace()
|
2015-01-18 12:58:28 +00:00
|
|
|
# embed ipython itself
|
|
|
|
snippet iem
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('IPython').embed()
|
2015-02-04 10:43:54 +00:00
|
|
|
# remote python debugger (rpdb)
|
|
|
|
snippet rpdb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('rpdb').set_trace()
|
2017-05-02 12:42:08 +00:00
|
|
|
# web python debugger (wdb)
|
|
|
|
snippet wdb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('wdb').set_trace()
|
2015-07-13 10:22:46 +00:00
|
|
|
# ptpython
|
|
|
|
snippet ptpython
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('ptpython.repl', fromlist=('repl')).embed(globals(), locals(), vi_mode=${1:False}, history_filename=${2:None})
|
2013-07-17 23:06:05 +00:00
|
|
|
# python console debugger (pudb)
|
|
|
|
snippet pudb
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('pudb').set_trace()
|
2020-04-26 01:56:16 +00:00
|
|
|
# python console debugger remote (pudb)
|
|
|
|
snippet pudbr
|
|
|
|
from pudb.remote import set_trace
|
|
|
|
set_trace()
|
2015-12-08 13:20:04 +00:00
|
|
|
# pdb in nosetests
|
|
|
|
snippet nosetrace
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('nose').tools.set_trace()
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet pprint
|
2017-11-24 13:54:40 +00:00
|
|
|
__import__('pprint').pprint(${1})
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet "
|
2015-07-13 10:22:46 +00:00
|
|
|
"""${0:doc}
|
2012-08-17 03:41:25 +00:00
|
|
|
"""
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2013-11-16 19:45:48 +00:00
|
|
|
# assertions
|
|
|
|
snippet a=
|
|
|
|
self.assertEqual(${0}, ${1})
|
2012-08-17 03:41:25 +00:00
|
|
|
# test function/method
|
|
|
|
snippet test
|
|
|
|
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2012-08-17 03:41:25 +00:00
|
|
|
# test case
|
|
|
|
snippet testcase
|
|
|
|
class ${1:ExampleCase}(unittest.TestCase):
|
2013-07-17 23:06:05 +00:00
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
def test_${2:description}(self):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2017-11-24 13:54:40 +00:00
|
|
|
# test given when then
|
|
|
|
snippet tgwt
|
|
|
|
# given: ${1}
|
|
|
|
# when: ${2}
|
|
|
|
# then: ${3}
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet fut
|
2013-11-16 19:45:48 +00:00
|
|
|
from __future__ import ${0}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2013-04-13 17:45:21 +00: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-07-17 23:06:05 +00:00
|
|
|
|
2013-04-13 17:45:21 +00:00
|
|
|
except getopt.GetoptError, err:
|
|
|
|
# Print debug info
|
|
|
|
print str(err)
|
|
|
|
${3:error_action}
|
|
|
|
|
|
|
|
for option, argument in opts:
|
|
|
|
if option in ("-h", "--help"):
|
2013-11-16 19:45:48 +00:00
|
|
|
${0}
|
2013-04-13 17:45:21 +00:00
|
|
|
elif option in ("-v", "--verbose"):
|
|
|
|
verbose = argument
|
2022-08-08 13:45:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
# argparse
|
|
|
|
snippet addp
|
|
|
|
parser = ${VISUAL:argparse.}ArgumentParser()
|
|
|
|
snippet addsp
|
|
|
|
${0:sub_parser} = parser.add_subparsers().add_parser("${1:name}")
|
|
|
|
snippet addarg
|
|
|
|
parser.add_argument("${0:short_arg}", "${1:long_arg}", default=${2:None}, help="${3:Help text}")
|
|
|
|
snippet addnarg
|
2021-06-23 09:57:12 +00:00
|
|
|
parser.add_argument("${0:arg}", nargs="${1:*}", default=${2:None}, help="${3:Help text}")
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet addaarg
|
|
|
|
parser.add_argument("${0:arg}", "${1:long_arg}", action="${2:store_true}", default=${3:False}, help="${4:Help text}")
|
|
|
|
snippet pargs
|
|
|
|
"${VISUAL:return }"parser.parse_args()
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2013-05-26 00:31:29 +00:00
|
|
|
# logging
|
|
|
|
# glog = get log
|
|
|
|
snippet glog
|
|
|
|
import logging
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER = logging.getLogger(${0:__name__})
|
2013-05-26 00:31:29 +00:00
|
|
|
snippet le
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER.error(${0:msg})
|
2013-07-17 23:06:05 +00:00
|
|
|
# conflict with lambda=ld, therefor we change into Logger.debuG
|
|
|
|
snippet lg
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER.debug(${0:msg})
|
2013-05-26 00:31:29 +00:00
|
|
|
snippet lw
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER.warning(${0:msg})
|
2013-05-26 00:31:29 +00:00
|
|
|
snippet lc
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER.critical(${0:msg})
|
2013-05-26 00:31:29 +00:00
|
|
|
snippet li
|
2017-11-24 13:54:40 +00:00
|
|
|
LOGGER.info(${0:msg})
|
2013-08-03 12:50:12 +00:00
|
|
|
snippet epydoc
|
2015-07-13 10:22:46 +00:00
|
|
|
"""${1:Description}
|
2013-08-03 12:50:12 +00:00
|
|
|
|
|
|
|
@param ${2:param}: ${3: Description}
|
|
|
|
@type $2: ${4: Type}
|
|
|
|
|
|
|
|
@return: ${5: Description}
|
|
|
|
@rtype : ${6: Type}
|
|
|
|
|
2013-11-16 19:45:48 +00:00
|
|
|
@raise e: ${0: Description}
|
2013-08-03 12:50:12 +00:00
|
|
|
"""
|
2014-04-18 12:58:02 +00:00
|
|
|
snippet dol
|
|
|
|
def ${1:__init__}(self, *args, **kwargs):
|
2022-08-08 13:45:56 +00:00
|
|
|
super(${0:ClassName}, self).$1(*args, **kwargs)
|
2014-04-18 12:58:02 +00:00
|
|
|
snippet kwg
|
|
|
|
self.${1:var_name} = kwargs.get('$1', ${2:None})
|
|
|
|
snippet lkwg
|
|
|
|
${1:var_name} = kwargs.get('$1', ${2:None})
|
2015-01-18 12:58:28 +00:00
|
|
|
snippet args
|
|
|
|
*args${1:,}${0}
|
|
|
|
snippet kwargs
|
|
|
|
**kwargs${1:,}${0}
|
|
|
|
snippet akw
|
|
|
|
*args, **kwargs${1:,}${0}
|
2017-11-24 13:54:40 +00:00
|
|
|
|
|
|
|
# comprehensions
|
|
|
|
snippet lcp list comprehension
|
|
|
|
[${1} for ${2} in ${3:${VISUAL}}]${0}
|
|
|
|
|
|
|
|
snippet dcp dict comprehension
|
|
|
|
{${1}: ${2} for ${3} in ${4:${VISUAL}}}${0}
|
|
|
|
|
|
|
|
snippet scp set comprehension
|
|
|
|
{${1} for ${2} in ${3:${VISUAL}}}${0}
|
2018-02-04 11:35:08 +00:00
|
|
|
|
|
|
|
snippet contain "methods for emulating a container type" b
|
|
|
|
def __len__(self):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __setitem__(self, key, value):
|
|
|
|
${3:pass}
|
|
|
|
|
|
|
|
def __delitem__(self, key):
|
|
|
|
${4:pass}
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
${5:pass}
|
|
|
|
|
|
|
|
def __reversed__(self):
|
|
|
|
${6:pass}
|
|
|
|
|
|
|
|
def __contains__(self, item):
|
|
|
|
${7:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet context "context manager methods" b
|
|
|
|
def __enter__(self):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
|
|
${2:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet attr "methods for customizing attribute access" b
|
|
|
|
def __getattr__(self, name):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __setattr__(self, name, value):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __delattr__(self, name):
|
|
|
|
${3:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet desc "methods implementing descriptors" b
|
|
|
|
def __get__(self, instance, owner):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __set__(self, instance, value):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __delete__(self, instance):
|
|
|
|
${3:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet cmp "methods implementing rich comparison"
|
|
|
|
def __eq__(self, other):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __ne__(self, other):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __lt__(self, other):
|
|
|
|
${3:pass}
|
|
|
|
|
|
|
|
def __le__(self, other):
|
|
|
|
${4:pass}
|
|
|
|
|
|
|
|
def __gt__(self, other):
|
|
|
|
${5:pass}
|
|
|
|
|
|
|
|
def __ge__(self, other):
|
|
|
|
${6:pass}
|
|
|
|
|
|
|
|
def __cmp__(self, other):
|
|
|
|
${7:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
snippet repr "methods implementing string representation"
|
|
|
|
def __repr__(self):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
${3:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
# note: reflected operands and augmented arithmeitc assignements have been
|
|
|
|
# intentionally ommited to reduce verbosity.
|
|
|
|
snippet numeric "methods for emulating a numeric type" b
|
|
|
|
def __add__(self, other):
|
|
|
|
${1:pass}
|
|
|
|
|
|
|
|
def __sub__(self, other):
|
|
|
|
${2:pass}
|
|
|
|
|
|
|
|
def __mul__(self, other):
|
|
|
|
${3:pass}
|
|
|
|
|
|
|
|
def __div__(self, other):
|
|
|
|
${4:pass}
|
|
|
|
|
|
|
|
def __truediv__(self, other):
|
|
|
|
${5:pass}
|
|
|
|
|
|
|
|
def __floordiv__(self, other):
|
|
|
|
${6:pass}
|
|
|
|
|
|
|
|
def __mod__(self, other):
|
|
|
|
${7:pass}
|
|
|
|
|
|
|
|
def __divmod__(self, other):
|
|
|
|
${8:pass}
|
|
|
|
|
|
|
|
def __pow__(self, other):
|
|
|
|
${9:pass}
|
|
|
|
|
|
|
|
def __lshift__(self, other):
|
|
|
|
${10:pass}
|
|
|
|
|
|
|
|
def __rshift__(self, other):
|
|
|
|
${11:pass}
|
|
|
|
|
|
|
|
def __and__(self, other):
|
|
|
|
${12:pass}
|
|
|
|
|
|
|
|
def __xor__(self, other):
|
|
|
|
${13:pass}
|
|
|
|
|
|
|
|
def __or__(self, other):
|
|
|
|
${14:pass}
|
|
|
|
|
|
|
|
def __neg__(self):
|
|
|
|
${15:pass}
|
|
|
|
|
|
|
|
def __pos__(self):
|
|
|
|
${16:pass}
|
|
|
|
|
|
|
|
def __abs__(self):
|
|
|
|
${17:pass}
|
|
|
|
|
|
|
|
def __invert__(self):
|
|
|
|
${18:pass}
|
|
|
|
|
|
|
|
def __complex__(self):
|
|
|
|
${19:pass}
|
|
|
|
|
|
|
|
def __int__(self):
|
|
|
|
${20:pass}
|
|
|
|
|
|
|
|
def __long__(self):
|
|
|
|
${21:pass}
|
|
|
|
|
|
|
|
def __float__(self):
|
|
|
|
${22:pass}
|
|
|
|
|
|
|
|
def __oct__(self):
|
|
|
|
${22:pass}
|
|
|
|
|
|
|
|
def __hex__(self):
|
|
|
|
${23:pass}
|
|
|
|
|
|
|
|
def __index__(self):
|
|
|
|
${24:pass}
|
|
|
|
|
|
|
|
def __coerce__(self, other):
|
|
|
|
${25:pass}
|
2019-03-08 11:04:56 +00:00
|
|
|
|
2022-09-20 08:08:31 +00:00
|
|
|
# Printing
|
|
|
|
snippet pr
|
|
|
|
print($0)
|
|
|
|
snippet prs
|
|
|
|
print("$0")
|
|
|
|
snippet prf
|
|
|
|
print(f"$0")
|
|
|
|
snippet fpr
|
|
|
|
print($0, file=${1:sys.stderr})
|
|
|
|
snippet fprs
|
|
|
|
print("$0", file=${1:sys.stderr})
|
|
|
|
snippet fprf
|
|
|
|
print(f"$0", file=${1:sys.stderr})
|