Archive for the ‘Python’ Category

2016 – the year of Python 3

Given I’ve posted before on the issues with Python 2 and unicode, it’s worth noting that there is a simple solution – upgrade to Python 3. The libraries have now finally reached a point where they are, by and large, dual stack compatible, or have unofficial forks to get you through (e.g. Fabric and Fabric3). […]

Posted on November 21, 2016 at 11:24 pm by Carlos Corbacho · Permalink · Leave a comment
In: Python

Using Selenium with PhantomJS

If you don’t want to play around with things like CasperJS to do your simple browser automation, it turns out that PhantomJS has WebDriver support, and in turn, Selenium supports it. To use it via the Python bindings, you’ll need to: 1) Install PhantomJS somewhere 2) Install Selenium from PyPi (or install it with Pip) […]

Posted on April 18, 2014 at 8:28 pm by Carlos Corbacho · Permalink · Leave a comment
In: Python, Web

Varnish and Ajax

If you have endpoints on your site that serve up both HTML and JSON depending on the request type, not the URL, then you need to tell Varnish to add this as an extra hash so that it doesn’t return JSON to clients expecting HTML, and vice versa. Oddly, I’ve not actually seen any examples […]

Posted on August 9, 2013 at 11:03 pm by Carlos Corbacho · Permalink · Leave a comment
In: Apache, Django, Varnish, Web

Psycopg2 and large result sets

Psycopg2 has a bit of a gotcha when it comes to fetching result sets that can catch out the unsuspecting developer. By default, it does not actually use cursors, but simply emulate them. In practical terms, this means that the entire result set of your query is fetched by the client into memory. It is […]

Posted on April 15, 2013 at 11:02 pm by Carlos Corbacho · Permalink · Leave a comment
In: Linux, Python

Python 2 and Unicode

I’ve been meaning to write this up for a while, so let’s see how we go. One of the problems I have with Python 2 currently is that Unicode support is a bit of a hit and miss game. The problem is that Unicode was a bolt on extra in Python 2.x – in the […]

Posted on October 28, 2010 at 9:31 pm by Carlos Corbacho · Permalink · Leave a comment
In: Python