Posts

Showing posts with the label python

Pythonic If-else 读书笔记

Image
https://mp.weixin.qq.com/s/tT4DYZn2jNfkn3TzqBqhEg   不是最优的方式, 使用if else Pythonic方式  把判断条件作为函数的输入,  使用handers 字典, 然后字典的键,是条件, 值 是具体处理函数

Manage python with pyenv and poetry

Update pyenv version cd ~/.pyenv git pull Use new version pyenv install 3.9.0 pyenv global 3.9.0 pyenv local 3.9.0 eval "$(pyenv init -)" pyenv shell 3.9.0 poetry init poetry install  poetry env use 3.9.0 poetry shell poetry add <dependencies>  <dependencies> poetry add -D <dependencies>  <dependencies> // existing project :   $ for item in $(cat requirements.txt); do poetry add "${item}"; done poetry shell code . https://www.pythoncheatsheet.org/blog/python-projects-with-poetry-and-vscode-part-2/ https://www.pythoncheatsheet.org/blog/python-projects-with-poetry-and-vscode-part-3/ https://aber.sh/articles/python-poetry/ install poetry install python from official site,  DO NOT add python to PATH, user have to be in venv to use python. poetry  init -   Create pyproject.toml poetry env use PYTHONPATH - Create virtual env,  PYTHONPATH is where python.exe poetry install & update,  install and update poetr...