Pycharm hidden gems

A few interesting features of Pycharm that are otherwise not commonly known or uses

Live templates

Live templates make it easy to add commonly used or otherwise annoying boiler plate code. I will not cover the existing live templates, you can have a look for yourself (File -> Settings [ctrl + alt + s] -> Editor -> Live Templates)

I do have a few custom ones to share that may be of interest

# Sanic route
async def $ROUTE$(_: Request) -> HTTPResponse:
    return response.json(['a', 'b'])

# Logger
import logging
logger = logging.getLogger(__name__)

# Data class
class $NAME$:
    test: str

# Data class json
class $NAME$:
    test: str

Post fix autocompletion

Post fix autocompletion can make writting certain Python constructs faster. For example if you want the following

if user.authorized:
    current_user = user

Instead of typing if user.authorized , you could type user.authorized.if and hit tab resulting in the if statement block and cursor on the next line.

The other supported postfix template are:

if a is None:

if a is not None:



if __name__ == '__main__':

not a


return a

while a:

To my dissapointment Pycharm currently does not support adding new post fix template for Python but for SQL.

Subscribe to Thulani S. Chivandikwa

Get the latest posts delivered right to your inbox

Thulani S. Chivandikwa

Thulani S. Chivandikwa

husband, dad, .net developer, tech and tea lover

Read More