CodeStandard/Python.txt

36 lines
858 B
Plaintext
Raw Permalink Normal View History

2024-06-07 20:00:25 +03:00
1. Use naming guidelines
https://www.python.org/dev/peps/pep-0008/#package-and-module-names
2. Use docstrings
https://www.python.org/dev/peps/pep-0257/
3. Basic input/output
in_file = open("input.txt", "r", encoding="utf-8")
lines = [line.strip() for line in in_file.readlines()]
in_file.close()
# process lines
lines = [process_line(line) for line in lines]
# output result
out_file = open("output.txt", "w", encoding="utf-8")
out_file.writelines([line + '\n' for line in lines])
out_file.close()
4. Install Virtual Env
$python -m venv $targetPath
5. Requirements
$python -m pip freeze > requirements.txt
OR
$python -m pip install --user pipenv
cd myproject
$python -m pipenv install requests
6. Reset Virtual Env
$python -m pip freeze > unins && pip uninstall -y -r unins && rm unins
7. Create wheels for project
$python -m pip wheel . -w $folder