Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Type Annotation in Python
Tips and Traps¶
Type hints cheat sheet (Python 3) is a quick cheat sheet showing how the PEP 484 type annotation notation represents various common types in Python 3.
Notice that the annotation on List and Tuple are different.
List[T]
stands for a variable length list of elements with typeT
Operators in Different Programming Languages
Python | Bash | C/C++ | Java | Julia | |
---|---|---|---|---|---|
and | and | -a | && | && | && |
or | or | -o | || | || | || |
not | not | ! | ! | ! | ! |
bit and | & | & | & | & | & |
bit or | | | | | | | | | | |
bit not | ~ | ~ | ~ | ~ | ~ |
bit xor | ^ | ^ | ^ | ^ | ^ |
vector and | |||||
vector or | |||||
vector not | |||||
equals | == | -eq | == | == | == |
not equal | != | -ne | != | != | != |
greater than | > | -gt | > | > | > |
less than | < | -lt | < | < | < |
greater than or equal to | >= | -ge | >= | >= | >= |
less than or equal to … |
Tips on pylint
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Tips and Traps
Optional Pylint checkers in the extensions module
Message Control
-
Show ERROR messages only.
pylint -E some_script.py
-
Show ERROR and WARNING messages only.
pylint --disable=R,C some_script …
Write Unit Tests Using PyTest in Python
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Run pytest
in the root directory of your project to run all test suites.
You can run test cases in a specific test file (e.g., test_file.py
)
using the command …
Use Flake8 to Lint Python Scripts
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Configration
It is suggested that you put the configuration into a file named .flake8
in the root directory of your project.
When flake8 supports pyproject.toml
later,
it is best to …