Home

Awesome

Python snippets

Python snippets collections.

Initially ported from PyCharm, TextMate, SublimeText and other editors/IDEs.

If you'd like to contribute, feel free to submit a pull request on github

Thanks!

Features

Base snippets

AbbreviationDescription
env#!/usr/bin/env python
env3#!/usr/bin/env python3
enc# -- coding=utf-8 --
enco# coding=utf-8
fencfrom future import ...
fencofrom future import ... (no -*-)
imimport
fimfrom ... import ...
classNew class
classdNew dataclass
defsNew method
defNew function
dowhileDo while structure
adefAsync function
propertyNew property
enumNew Enum
ifif
forfor
lambdalambda expression
whilewhile
trytry:except:
tryeftry:except:else:finally:
tryetry:except:else:
tryftry:except:finally:
sself
__magic
ifmainif name == "main"

Comprehensions

AbbreviationDescription
lcList comprehension
lcieList comprehension if else
lciList comprehension if filter
dcDictionary comprehension
dciDictionary comprehension if filter
scSet comprehension
sciSet Comprehension if filter
gcGenerator comprehension
gciGenerator comprehension if filter

Unittest

AbbreviationDescription
aseAssert equal
asneAssert not equal
asrAssert raises
astAssert True
asfAssert False
asiAssert is
asintAssert is not
asinoAssert is None
asinnoAssert is not None
asinAssert in
asniAssert not in
asAssert
failFail (a test)

Debugging

AbbreviationDescription
pdbPDB set trace
ipdbiPDB set trace
rpdbrPDB set trace
pudbPuDB set trace

Tkinter

AbbreviationDescription
imtkImport Tkinter py2
imtk3Import tkinter py3
configRoot configuration
buttonButton
labelLabel
frameFrame
entryEntry
gridGrid
stickySticky
checkbuttonCheck button
mainloopMain loop
packPack
sideSide
bindBind
menuMenu
addcascadeAdd cascade
addcommandAdd command
addseperatorAdd seperator

Release Notes

See changelog for all changes and releases.

Troubleshooting

If you experience problems with the auto-formatting of certain snippets, make sure you have the option editor.tabCompletion set on onlySnippets or on.