Imports at a Distance
(Thanks to Mark Williams for feedback and research)
Imagine the following code:
## mymodule.py import toplevel.nextlevel.lowmodule def _func(): toplevel.nextlevel.lowmodule.dosomething(1) def main(): _func()
Assuming the toplevel.nextlevel.module
does define a function dosomething
,
this code seems to work just fine.
However, imagine that later we …
read moreX Why Zip
Nitpicks are for Robots
My Little Subclass: Inheritance is Magic
Learning about Python Method Resolution Order with Twilight Sparkle and her friends.
(Thanks to Ashwini Oruganti for her helpful suggestions.)
The show "My Little Pony: Friendship is Magic" is the latest reimagination of the "My Little Pony" brand as a TV show. The show takes place, mostly, in Ponyville and …
read morePYTHONPATH Considered Harmful
(Thanks to Tim D. Smith and Augie Fackler for reviewing a draft. Any mistakes that remain are mine.)
The environment variable PYTHONPATH
seems harmless enough.
The official documentation refers to its function as
"Augment the default search path for module files."
However, in practice, setting this variable in a shell …
Shipping Python Applications in Docker
Introduction
When looking in open source examples, or tutorials, one will often see Dockerfiles that look like this:
FROM python:3.6 COPY setup.py /mypackage COPY src /mypackage/src COPY requirements.txt / RUN pip install -r /requirements.txt RUN pip install /mypackage ENTRYPOINT ["/usr/bin/mypackage-console-script", "some", "arguments"]
This …