Skip to content

Python

Programming language.

Resources

Naming conventions and style guide

Defined in PEP 81

Things I often forget:

  • Variable names: snake_case
    • some_random_variable = "test string"
  • Class names: PascalCase
    • class SomeClass():
    • This applies to models in Django as well, since they're really just classes anyway2.

Virtual environments

Create a new virtual environment named .env in the current directory. Do this from a terminal in VSCode and it'll ask if you want to select it for the current workspace, which is helpful for many things. More info: Using Python Environments in Visual Studio Code

python -m venv .env

Decorators

Syntactic sugar around functions that return functions. Makes it nice to add functionality to existing functions in an efficient and readable way. More information: https://docs.python.org/3/glossary.html#term-decorator