Everything I know about Python...

Learn to Write Pythonic Code!

Check out the book Writing Idiomatic Python!

Discuss Posts With Other Readers at discourse.jeffknupp.com!

How Python Linters Will Save Your Large Python Project

A Python project I'm working on at Enigma is starting to grow rather large. I spent a good deal of effort yesterday getting a five line change added to our Makefile (which is run as part of our CI and CD pipeline on every pull request and merge). After the PR was merged, I gloated to others how awesome my team's project was. Here are the five lines:

lint:
    pylint --rcfile=.pylintrc api -f parseable -r n && \
    mypy --silent-imports api && \
    pycodestyle api --max-line-length=120 && \
    pydocstyle api

For completeness sake, here is the test target that actually gets run as part of CI tests:

test: install lint
    python3 setup.py test --addopts="--cov=api"
    coverage xml -i -o coverage/cobertura-coverage.xml --omit=$(VIRTUAL_ENV)/*,.eggs/*

(So, for those not versed in "Makefile-ese", the test target won't run successfully if the lint target doesn't do so first).

Why was I happy enough to be a jerk to other engineers and brag about those five lines? It all comes down to complexity.

Read on →


How Python Makes Working With Data More Difficult in the Long Run

Before we begin, let's be clear on terminology. When I refer to "working with data" in the context of software development I could mean one of two things:

  1. Interactively working with data, with perhaps Jupyter (née IPython) or the live interpreter
  2. Writing, testing, reading, reviewing and maintaining programs that primarily manipulate data

In short: Python is awesome for interactive data analysis but terrible for writing long-lived programs dealing with complicated data structures.

Read on →




Python, sandman2, and Open Data

sandman2 (and its predecessor, sandman) has been far and away my most successful open source project. I fully attribute this to its genuine usefulness. It is most often used as a command line tool, through which you provide the connection details of a legacy database and run it, and in return it starts both a RESTful API service for your data, as well as a web-based UI that allows you to add, delete, and edit rows directly. For many (especially in the enterprise), interacting with legacy databases is a pain at best, and impossible at worst. The ability to access data via a simple REST API, then, is a godsend.

Read on →


Web Analytics