Skip to content

Instantly share code, notes, and snippets.

@maxwelllevin
Last active January 13, 2024 01:25
Show Gist options
  • Save maxwelllevin/02afa634b0a5b02db90e0b54b1d314a6 to your computer and use it in GitHub Desktop.
Save maxwelllevin/02afa634b0a5b02db90e0b54b1d314a6 to your computer and use it in GitHub Desktop.
Python resources

Many Python Things

Some resources I've collected over a few years of working mostly in Python.

General

  • Python Cheatsheet: A guide to Python syntax and grammar.
  • Awesome Python: A comprehensive and curated list of Python resources.
  • Calm Code: A series of video shorts on useful Python libraries for data management and software best practices.
  • ArjanCodes: A YouTuber who produces super high-quality educational videos focused on software engineering.

For Data, Science

  • numpy: A must-know library for working with data in Python. Check out this awesome guide for more info.
  • xarray: A great library for working with the netCDF files or multidimensional labelled data.
  • pandas: Working with tabular data? Use pandas.
  • scipy: A library that provides performant implementations of many mathematical operations. Built on top of numpy.
  • matplotlib: The most popular Python library for creating scientific plots.
  • sympy: Solve mathematical equations symbolically.
  • act-atmos: Toolkit for the atmospheric sciences, developed by colleagues at ARM. Great when paired with xarray.
  • plotly dash: Leading python framework for creating data dashboards.
  • streamlit: A fantastic alternative to plotly that gives you results fast.

For Web Development

  • FastAPI: A modern, high-performance web framework for building APIs using standard Python type hints.
  • Django: A very popular and fully-featured framework for full-stack web development.
  • flask: A lightweight framework for microservices and API development. Less features than django, but far easier to use.

Fancy Utilities

  • datetime: Easily handle logic related to dates, times, or timezones. Also see this table for datetime string conversions.
  • pathlib: Stop using os; use pathlib instead.
  • logging: Use the logging standard library to easily configure different logging verbosities for your scripts.
  • tqdm: Want to add a progress bar to your code? tqdm makes this easy.
  • rich: Add colors, tables, and more to your console output to take your logging to the next level.
  • typer: Want to make a command-line interface for your script? Easy.
  • pydantic: create and validate data structures using intuitive type-hinting.
  • cookiecutter: Automate the boilerplate with cookiecutter.

Development Environments

Best Practices

  • GitHub: Use git and GitHub to track changes to your code and share it with others.
  • Dependencies: Use a requirements.txt file to track your project's dependencies.
  • ruff: The fastest linter for python available. Also formats your code according to the standard black code style, making your code more readable for your future self.
  • mypy: Use mypy to statically type-check your code to catch potentially buggy behavior before it becomes an actual problem.
  • pytest: Ensure your code is well-tested with pytest.
  • pyinstrument: Profile your code to identify bottlenecks.
  • PEP 20: Follow the Zen of Python when writing code. (Run import this to read it at any time)

Advanced

  • Decorators: Decorators allow you to augment the behavior of your functions by wrapping them with other functions.
  • Dev Mode: Run Python in development mode to see more verbose warnings and identify other potential issues.
  • __dunder_methods__: Enhance your Python classes by defining dunder (double-underscore) methods.
  • __slots__: Make your objects faster and smaller with appropriate use of __slots__.
  • dask: Write parallelized code for distributed environments with dask.
  • numba: Speed up your Python and numpy code using "Just in Time" compilation with numba.
  • prefect: Easily script workflows by defining Tasks and Flows as code and use prefect to orchestrate the rest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment