Skip to content

Latest commit

 

History

History
127 lines (99 loc) · 5.14 KB

README.md

File metadata and controls

127 lines (99 loc) · 5.14 KB

Python

Setup

  1. Install Python 3

    • On a Unix-based OS, the system's default Python installation is normally Python 2. Check this by running python --version on a terminal. If this is so, install Python 3 but DO NOT REMOVE / OVERWRITE / UNINSTALL the old Python 2. The system uses Python 2 for its internal scripts and removing it may break the OS installation.
    • For Linux, either install it from apt or from source
    • For Mac, use Homebrew
    • Verify the Python installation by running
      $ which python3
      $ python3 --version
      
  2. Setup and use a virtual environment

  3. For each Python project

    • For virtualenv and venv
      • Create/Activate a virtual environment
        $ mkvenv NAME /path/to/python
        
      • Create a requirements.txt file
        $ pip freeze > requirements.txt
        
      • Commit the requirements.txt file
      • When switching environments:
        $ pip install -r requirements.txt
        
    • For poetry
      • Specify the Python version to use
        $ cd <project>
        $ poetry env use python3
        $ poetry env use python3.X # 3.7, 3.8, 3.9, 3.10, 3.11
      • Initialize the project
        $ poetry init
      • Install packages
        $ poetry add <package>
        $ pipenv add --dev PACKAGE
      • Commit the generated pyproject.toml and poetry.lock
      • Activate the environment
        $ poetry shell

FAQ

Coding Conventions

Package Management

Notable Modules

Linters

Formatters

  • black - no-config, opinioniated formatter

Terminal

  • ipython - Enhanced interactive Python shell

CLI

  • colorama - Cross-platform colorizer for console logs
  • click - For creating CLI-based applications
  • typer - For creating CLI-based applications with type-hinting support
  • tqdm - For better progress bars and loop tracking

Web Application

  • flask - Lightweight web application framework
  • fastapi - Modern framework with async support, type-hints, and auto-generated documentation

Data Validation

  • pydantic - Data validation through type hints

Data Visualization

  • bokeh - Interactive and embeddable images for modern web browsers