py
Last updated
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # uv/uvx/uvw , v0.9.2 < 60MB
curl -LsSf https://astral.sh/uv/install.sh | sh # uv/uvx
uv self update # ~/.local/bin (win+linux)
uv python install 3.14 3.12 # around 20MB each
uv python list # supported versions & local path
cd $path
uv venv --python 3.14 --seed # cat .venv/pyvenv.cfg
uv tool run jupyter lab # v4.4.9 : 99 packages
uv tool run --from jupyter-core jupyteruv run example.py
echo 'print("hello world!")' | uv run -
uv run - <<EOF
print("hello world!")
EOF$cd example
$ uv add ruff
Creating virtual environment at: .venv
$ uv run ruff check
$ uv lock
$ uv syncuv run --with jupyter jupyter lab # pyproject.toml or uv.lockAnaconda3\condabin>conda.bat activate
~/.bashrc # conda initialize
conda config --set auto_activate_base false
conda create -n py3.14 python=3.14# __init__.py
import os, sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))Debian 7 wheezy 2.7.3 / 3.2
Debian 8 jessie 2.7.9 / 3.4
Debian 9 stretch 2.7.13 / 3.5
Debian 10 buster 2.7.14 / 3.6
Debian 11 bullseye 3.9# online
pip install git+ https://github.com/<owner_name>/<repo_name>.git
# local
pip install --download DIR -r requirements.txt
pip wheel --wheel-dir DIR -r requirements.txt
pip install --no-index --find-links=DIR -r requirements.txtexport all_proxy="socks5://x:y" # cause python error: Missing dependencies for SOCKS support.
pip install --proxy=https://user@mydomain:port somepackagetwine upload --repository testpypi dist/*import fire
english = 'Hello World'
fire.Fire()
# .py english
fire.Fire(lambda obj: type(obj).__name__)
# .py 10 / "10" # output: int
# .py '"10"' / "'10'" / \"10\" # output: str
# .py '{"name": "David Bieber"}' # notice the quote, output: dict
# .py {"name":"David Bieber"} # Wrong. output: str
# .py --obj=True / --obj
# .py --obj=False / --noobj
def hello(name):
return 'Hello {name}!'.format(name=name)
if __name__ == '__main__':
fire.Fire()
# .py hello name_value
class Calculator(object):
def add(self, x, y):
return x + y
if __name__ == '__main__':
fire.Fire(Calculator)
# .py add 10 20
class BrokenCalculator(object):
def __init__(self, offset=1):
self._offset = offset
def add(self, x, y):
return x + y + self._offset
if __name__ == '__main__':
fire.Fire(BrokenCalculator)
# .py add 10 20 --offset=0
class Airport(object):
def __init__(self, code):
self.code = code
self.name = fn_x(self.code)
if __name__ == '__main__':
fire.Fire(Airport)
# .py --code=SJC name
tomorrow = pendulum.now().add(days=1)
last_week = pendulum.now().subtract(weeks=1)
if pendulum.now().is_weekend():
past.diff_for_humans()# bug: https://github.com/DonJayamanne/pythonVSCode/issues/981#issuecomment-308085243
pip install ptvsd==3.0.0 import ptvsd
ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
ptvsd.wait_for_attach()