Fetch Current Bitcoin Price with Python

Using the MtGox API, you can easily fetch the current Bitcoin price using a very small Python script. import requests url = ‘http://data.mtgox.com/api/2/BTCUSD/money/ticker’ r = requests.get(url, headers={‘Accept’: ‘application/json’}) print r.json()[‘data’][‘avg’][‘display_short’] If you want to support for multiple currencies and more information, here’s an extended version: # -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals […]

Read More

Why Are There So Many Pythons? A Python Implementation Comparison

Python is amazing. Surprisingly, that’s a fairly ambiguous statement. What do I mean by ‘Python’? Do I mean Python the abstract interface? Do I mean CPython, the common Python implementation? Or do I mean something else entirely? Maybe I’m obliquely referring to Jython, or IronPython, or PyPy. Or maybe I’ve really gone off the deep […]

Read More

Pillow 2-1-0 is Out

Pillow is a popular fork of PIL by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors Pillow 2.1.0 is out! With this release, the Pillow team has finally removed support for “import _imaging”, thus completing the move of PIL modules into the PIL namespace [1]. Many thanks to […]

Read More

Heroku Buildpack for Numpy, Scipy and Scikit-Learn

(TLDR: https://github.com/dbrgn/heroku-buildpack-python-sklearn) Background At Webrepublic we just launched a Python based system that among other things does comparison of large texts using tf-idf vectors in a multi-dimensional vector space and measuring the cosine similarity between them (see http://stackoverflow.com/a/8897648/284318). For this, we needed scikit-learn. During the deployment process, I discovered that one does not simply deploy […]

Read More

IPython Notebook

Last PyCon US (2013) I attended, there were many interesting talks, but if I had to talk about what’s happening, what’s the trend, between other things I would mention IPython Notebook. In a few words: it’s an excellent tool, you can have an IPython console within your web browser where you can write code snippets […]

Read More

Using Jedi with YouCompleteMe

(In case you’re not familiar with it yet, Jedi is an awesome autocompletion library for Python that tries to understand your code. There are editor plugins available for Vim, Emacs and Sublime Text 2.) The “official” Jedi plugin for vim is jedi-vim, but there’s another vim autocompletion plugin that supports Jedi: YouCompleteMe. In contrast to […]

Read More

Enums in Python

Until now, if you wanted to use enumeration types in Python you had to fall back to a class-attribute approach: >>> class Color(object): … RED = 1 … GREEN = 2 … BLUE = 3 … >>> print(Color.RED) 1 This has different downsides, for example with representation (Color.RED is represented as an integer, not as […]

Read More

New Pyramid Site

For the first time in 10 years, http://aclark.net is not powered by Plone. Nothing against Plone: it’s still one of the greatest loves of my life (inasmuch as you can love a software and community, as I do). Why This was not the result of a revolutionary plan, rather more of an evolution. It happened […]

Read More