mirror of
				https://github.com/tiyn/dotfiles.git
				synced 2025-11-04 06:21:16 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			200 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			200 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# shbang 3
 | 
						|
snippet #!
 | 
						|
	#!/usr/bin/env python3
 | 
						|
 | 
						|
# shbang 2
 | 
						|
snippet #!2
 | 
						|
	#!/usr/bin/env python2
 | 
						|
	# -*- coding: utf-8 -*-
 | 
						|
 | 
						|
# shbang 3
 | 
						|
snippet #!3
 | 
						|
	#!/usr/bin/env python3
 | 
						|
 | 
						|
# import
 | 
						|
snippet imp
 | 
						|
	import ${0:module}
 | 
						|
 | 
						|
# from ... import
 | 
						|
snippet from
 | 
						|
	from ${1:package} import ${0:module}
 | 
						|
 | 
						|
# while
 | 
						|
snippet wh
 | 
						|
	while ${1:condition}:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# do ... while
 | 
						|
snippet dowh
 | 
						|
	while True:
 | 
						|
		${1}
 | 
						|
		if ${0:condition}:
 | 
						|
			break
 | 
						|
 | 
						|
# with
 | 
						|
snippet with
 | 
						|
	with ${1:expr} as ${2:var}:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# async with
 | 
						|
snippet awith
 | 
						|
	async with ${1:expr} as ${2:var}:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# class
 | 
						|
snippet cla
 | 
						|
	class ${1:class_name}:
 | 
						|
		"""${0:description}"""
 | 
						|
 | 
						|
# class with init
 | 
						|
snippet clai
 | 
						|
	class ${1:class_name}:
 | 
						|
		"""${2:description}"""
 | 
						|
		def __init__(self, ${3:args}):
 | 
						|
			${0}
 | 
						|
 | 
						|
# function with docstring
 | 
						|
snippet def
 | 
						|
	def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
 | 
						|
		"""${3:docstring for $1}"""
 | 
						|
		${0}
 | 
						|
 | 
						|
# function
 | 
						|
snippet deff
 | 
						|
	def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
 | 
						|
		${0}
 | 
						|
 | 
						|
# async function with docstring
 | 
						|
snippet adef
 | 
						|
	async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
 | 
						|
		"""${3:docstring for $1}"""
 | 
						|
		${0}
 | 
						|
 | 
						|
# async function
 | 
						|
snippet adeff
 | 
						|
	async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
 | 
						|
		${0}
 | 
						|
 | 
						|
# init function
 | 
						|
snippet defi
 | 
						|
	def __init__(self, ${1:args}):
 | 
						|
		${0}
 | 
						|
# if
 | 
						|
snippet if
 | 
						|
	if ${1:condition}:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# else
 | 
						|
snippet el
 | 
						|
	else:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# else if
 | 
						|
snippet ei
 | 
						|
	elif ${1:condition}:
 | 
						|
		${0:${VISUAL}}
 | 
						|
 | 
						|
# for
 | 
						|
snippet for
 | 
						|
	for ${1:item} in ${2:items}:
 | 
						|
		${0}
 | 
						|
 | 
						|
# return
 | 
						|
snippet ret
 | 
						|
	return ${0}
 | 
						|
 | 
						|
# self reference
 | 
						|
snippet .
 | 
						|
	self.
 | 
						|
 | 
						|
# self attribute
 | 
						|
snippet sa self.attribute = attribute
 | 
						|
	self.${1:attribute} = $1
 | 
						|
 | 
						|
# try ... except
 | 
						|
snippet try Try/Except
 | 
						|
	try:
 | 
						|
		${1:${VISUAL}}
 | 
						|
	except ${2:Exception} as ${3:e}:
 | 
						|
		${0:raise $3}
 | 
						|
 | 
						|
# try ... except ... else
 | 
						|
snippet trye Try/Except/Else
 | 
						|
	try:
 | 
						|
		${1:${VISUAL}}
 | 
						|
	except ${2:Exception} as ${3:e}:
 | 
						|
		${4:raise $3}
 | 
						|
	else:
 | 
						|
		${0}
 | 
						|
 | 
						|
# try ... except ... finally
 | 
						|
snippet tryf Try/Except/Finally
 | 
						|
	try:
 | 
						|
		${1:${VISUAL}}
 | 
						|
	except ${2:Exception} as ${3:e}:
 | 
						|
		${4:raise $3}
 | 
						|
	finally:
 | 
						|
		${0}
 | 
						|
 | 
						|
# try ... except ... else ... finally
 | 
						|
snippet tryef Try/Except/Else/Finally
 | 
						|
	try:
 | 
						|
		${1:${VISUAL}}
 | 
						|
	except ${2:Exception} as ${3:e}:
 | 
						|
		${4:raise $3}
 | 
						|
	else:
 | 
						|
		${5}
 | 
						|
	finally:
 | 
						|
		${0}
 | 
						|
 | 
						|
# if name is main
 | 
						|
snippet ifmain
 | 
						|
	if __name__ == '__main__':
 | 
						|
		${0:main()}
 | 
						|
 | 
						|
# docstring
 | 
						|
snippet "
 | 
						|
	"""${0:doc}
 | 
						|
	"""
 | 
						|
 | 
						|
# test function
 | 
						|
snippet test
 | 
						|
	def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
 | 
						|
		${0}
 | 
						|
 | 
						|
# list comprehension
 | 
						|
snippet lcp list comprehension
 | 
						|
	[${1} for ${2} in ${3:${VISUAL}}]${0}
 | 
						|
 | 
						|
# dict comprehension
 | 
						|
snippet dcp dict comprehension
 | 
						|
	{${1}: ${2} for ${3} in ${4:${VISUAL}}}${0}
 | 
						|
 | 
						|
# set comprehension
 | 
						|
snippet scp set comprehension
 | 
						|
	{${1} for ${2} in ${3:${VISUAL}}}${0}
 | 
						|
 | 
						|
# print
 | 
						|
snippet pr
 | 
						|
	print($0)
 | 
						|
 | 
						|
# print string
 | 
						|
snippet prs
 | 
						|
	print("$0")
 | 
						|
 | 
						|
# fprint string
 | 
						|
snippet prf
 | 
						|
	print(f"$0")
 | 
						|
 | 
						|
# print to file
 | 
						|
snippet fpr
 | 
						|
	print($0, file=${1:sys.stderr})
 | 
						|
 | 
						|
# print string to file
 | 
						|
snippet fprs
 | 
						|
	print("$0", file=${1:sys.stderr})
 | 
						|
 | 
						|
# fprint string to file
 | 
						|
snippet fprf
 | 
						|
	print(f"$0", file=${1:sys.stderr})
 |