Python
Standard Library
- Standard Libraries complexity: https://www.geeksforgeeks.org/complexity-cheat-sheet-for-python-operations/
- Types: https://docs.python.org/3/library/stdtypes.html
- Data Structures:https://docs.python.org/3/tutorial/datastructures.html
Packages
- Standard Libraries: https://docs.python.org/3/library/index.html
- Modules/Packages: https://pypi.org/
Interpreter
- You can configure your IDE to use a python interpreter (the python binary) with a specific version
- The python binary can also be picked from your chosen virtual environment
- On vscode,
Python: Select Interpreter
Virtual Environment
- Each virtual environment is created based on a python interpreter (version)
- A virtual environment contains all libraries and binaries isolated from the operating system
- Even the python binary is isolated (although symlinked to the system python binary)
- Options
venv
: the native virtual environment solutionvirtualenv
: 3rd partypipenv
: 3rd party, more recent
python -m venv .venv
source ./.venv/bin/activate # bash
source ./.venv/bin/activate.fish # fish
echo $VIRTUAL_ENV
echo $PATH
Language Server
Jedi
: Community-driven-
Pylance
: Developed by Microsoft -
With homebrew, source files are installed at
/opt/homebrew/Cellar/[email protected]/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12
Linter & Formatter
Flake8
: By Microsoft
Expression vs. Statement
Statement
: any unit of codeExpression
: special statement that evaluates to some value
# Expression
1 + 2 # evaluates to 3
"a" if 1 != 1 else "b" # evaluates to "a"
# Statement (assignment)
foo = 1 + 2 # doesn't return any value