Get a Python Package Version
Part of maintaining a Django-based application like MDN's kuma is ensuring Python packages are up to date. I was recently testing an upgrade on a remote system and needed to ensure that a given Python package was at the version number it should be. Here's how I retrieved the package version:
import nose # Nose is a test utility. Replace with your desired package here.
nose.__version__
# Output: 0.3.1
The __version__
property returns the exact version number for a Python package. Some Python packages use a VERSION
property as well, but __version__
should be the most reliable.
For maximum performance, we all know we must put our assets on CDN (another domain). Along with those assets are custom web fonts. Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...
My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...
Did you know you can triple-heart things on CodePen? We’ve had that little not-so-hidden feature forever. You can click that little heart button on any Pen (or Project, Collection, or Post) on CodePen to show the creator a little love, but you can click it again...
You've probably noticed that I shy away from writing really long articles. Here are a few reasons why:
Most site visitors are coming from Google and just want a straight to the point, bail-me-out ASAP answer to a question.
I've noticed that I have a hard time...
Every once in a while a package might not define either
VERSION
or__version__
, since they’re conventions, not required. You can always get the installed version with pkg_resources, though:@James,
__version__
is recommended by PEP 396