Tips & Traps¶
- Please refer to Parse TOML File in Python for general tips on parsing TOML in Python.
Installatoion¶
Replace Single Quotes With Double Quotes in Python Code
There are 2 ways.
-
Format the Python code using black, which will automatically convert single quotes to double quotes when applicable. (Note that you can format the code again using yapf if you want the code to formatted by yapf finally.)
-
Use the tool myint/unify to help you.
Rename Rows and Columns in a pandas DataFrame
Python Logging
General Tips
Hands on the Python Module argparse
argparse
is the best library to use to parse command-line arguments in Python. It is included in Python standard libaries (which menas that you can use it out of the box).It is suggestedd that you always log a parsed Namespace object so that you can check whether it is as expected.
Static Type Checking of Python Scripts Using pytype
Configuration
There are 3 ways to control the behavior of `pytype.
-
Pass command-line options to
pytype
. -
Specify a configuration file using
pytype --config /path/to/config/file ...
. You can generate an example configuration file using the commandpytype --generate-config pytype.cfg
. -
If no configuration file is found, pytype uses the …