An introduction to zope.interface
This has previously been published on opensource.com.
The Zen of Python is loose enough and contradicts itself enough that you can prove anything from it. Let's meditate upon one of its most famous principles: "Explicit is better than implicit."
One thing that traditionally has been implicit in Python is …
read moreAdding Methods Retroactively
The following post was originally published on OpenSource.com as part of a series on seven libraries that help solve common problems.
Imagine you have a "shapes" library.
We have a Circle
class,
a Square
class,
etc.
A Circle
has a radius
,
a Square
has a side
,
and maybe Rectangle …
Designing Interfaces
One of the items of feedback I got from the article about interface immutability is that it did not give any concrete feedback for how to design interfaces. Given that they are forever, it would be good to have some sort of guidance.
The first item is that you want …
read moreInterfaces are forever
(The following talks about zope.interface interfaces, but applies equally well to Java interfaces, Go interfaces, and probably other similar constructs.)
When we write a function, we can sometimes change it in backwards-compatible ways. For example, we can loosen the type of a variable. We can restrict the type of …
read moreAnalyzing the Stack Overflow Survey
The Stack Overflow Survey Results for 2019 are in! There is some official analysis, that mentioned some things that mattered to me, and some that did not. I decided to dig into the data and see if I can find some things that would potentially interest my readership.
import csv …read more
Inbox Zero
I am the parent of two young kids. It is easy to sink into random stuff, and not follow up on goals. Strict time management and prioritization means I get to work on open source projects, write programming books and update my blog with a decent cadence. Since a lot …
read morePublishing a Book with Sphinx
A Local LRU Cache
"It is a truth universally acknowledged, that a shared state in possession of mutability, must be in want of a bug." -- with apologies to Jane Austen
As Ms. Austen, and Henrik Eichenhardt, taught us, shared mutable state is the root of all evil.
Yet, the official documentation of functools tells …
read moreDon't Make It Callable
There is a lot of code that overloads the
__call__
method.
This is the method that
"calling"
an object activates:
something(x, y, z)
will call
something.__call__(x, y, z)
if
something
is a member of a Python-defined class.
At first, like every operator overload, this seems like a …
read moreStaying Safe with Open Source
A couple of months ago, a successful attack against the Node ecosystem resulted in stealing an undisclosed amount of bitcoins from CoPay wallets.
The technical flow of the attack is well-summarized by the NPM blog post. Quick summary:
- nodemon, a popular way to run Node applications, depends on event-stream.
- The …