Sometimes, python modules in pypi.org is outdated a little bit but it's source code has already fixed what you wanted. You can install the said module directly using: 1## git clone the module-name from its repo, then 2python -m pip install -e ./module-name or in one line (replace the repo accordingly): 1pip install -e …
Read MoreBest approach in doing development in any language is to have an isolated dev environment. In python, we do it this way: 1python3 -m venv env 2source ./env/bin/activate See more options in https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/
Read MoreUse pdb module in debugging python: 1$ python3 -m pdb pdb_example.py and something like this: 1student@ubuntu:~$ python3 -m pdb pdb_example.py 2> /home/student/pdb_example.py(1)<module>() 3-> class Student: 4(Pdb) continue 50 61 72 83 94 10The program finished and will be restarted 11> …
Read MoreIf you ever need to serve your current directory via http for some reason, this is a quick command in python3: 1~$ python3 -m http.server 8000 Then access http://localhost:8000
Read MorePython Official Documentation Python Package Index or PyPI Python3 Standard Library Python3 Docs Learn Python PyNative Learn Python in Y minutes Python Frameworks Django Project Flask Bottle Others Beautiful Soup - HTML & XML web scraping Stackoverflow: Other alternatives to venv Build REST API with Django …
Read MoreThese are the three core data types in python. Of course there are strings, int too. I'm listing this here as I often forget these: List Somewhat similar to tuple (see below) but changeable. Uses square brackets instead of parenthesis in tuple. 1>>> kirk = ["James Kirk", 34, "Captain", 2265] …
Read MoreUse enumerate to iterate to each list's element 1>>> # Pythonic Example 2>>> animals = ['cat', 'dog', 'moose'] 3>>> for i, animal in enumerate(animals): 4... print(i, animal) 5... 60 cat 71 dog 82 moose If the index is not important, use "_" in place of …
Read More