Sublime Forum

Function snippet for Python with auto-Docstring arg list

#1

I created a new tab snippet for ‘def’ with the aim of encouraging good DocString habits (per PEP 257) and Type Hinting (PEP 484). The snippet uses a sophisticated RegEx to parse variable names from parameters that may include strings, nested arrays, type hints, etc. and autopopulates an args list.

Two tricks are included that may be helpful for other’s snippets / plugins:

  • scope-dependent key-bindings to disable autopairing within function parameters (which would end the snippet)
  • subroutine recursion within a regular expression

github.com/tbenst/Sublime-Python-Snippets

I welcome any comments / feedback!

0 Likes