Skip to content

Instantly share code, notes, and snippets.

@cdwilson
Last active May 18, 2016 04:36
Show Gist options
  • Save cdwilson/5863580 to your computer and use it in GitHub Desktop.
Save cdwilson/5863580 to your computer and use it in GitHub Desktop.
Python tips and tricks

Documentation

Google Style Guide - Comments

https://google.github.io/styleguide/pyguide.html#Comments

Python Developer's Guide - Documenting Python

https://docs.python.org/devguide/documenting.html

Sphinx Napoleon

http://sphinxcontrib-napoleon.readthedocs.io/en/latest/

PEP 257 -- Docstring Conventions

https://www.python.org/dev/peps/pep-0257/

Doctest

https://docs.python.org/2/library/doctest.html#module-doctest

Building Python

Install python as a framework on OS X with pyenv

env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" pyenv install 2.7.11

Install python as a framework on OS X with pyenv (support matplotlib)

pyenv/pyenv-virtualenv#140

env PYTHON_CONFIGURE_OPTS="--enable-framework --enable-unicode=ucs2 CC=clang" pyenv install 2.7.11

Code Snippits

bin() with leading zeros

def lzbin(x):
    return "0b"+bin(x)[2:].zfill(8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment