cat /dev/brain

Articles with the python tag

Making Python Faster with Rust and CFFI, or Not

Recently, I had the (genuine) joy of helping port a Python library with a C extension to work on Python 2 and Python 3. C was my first language that I really understood pretty well and I have some (possibly misplaced) nostalgia for the time when I only ever wrote …

Posted on 07 January 2018 by Ian Stapleton Cordasco

API Client Design Decisions

Every API client is different. They are shaped by many things, including:

  • the author's personal tastes
  • the language and its conventions
  • the API itself
  • the underlying HTTP library

People have told me that they love and how I designed it. Personally, I feels there is room for significant …

Posted on 22 January 2017 by Ian Cordasco

Flake8 3.0 beta Released!

Today, I released Flake8 3.0.0b1. You can try it out by running:

pip install --pre flake8

This marks the start of the culmination of several months worth of work and a couple years of hammock driven development (mostly spent ruminating). You can read about the list of changes …

Posted on 25 June 2016 by Ian Cordasco

Betamax 0.5.0 Now With A PyTest Fixture

Tonight marks the release of Betamax 0.5.0. Beyond just reworking the documentation, it also marks the addition of two integrations with popular testing frameworks. Betamax now ships with a pytest fixture that provides an instantiated Session that is being recorded by Betamax. Let's look at how we might …

Posted on 15 July 2015 by Ian Cordasco

Moving PEP8 to the PyCQA

tl;dr pep8's repository has moved from Johann Rocholl's account to the Python Code-Quality Authority organization.

It's my great pleasure to announce that the pep8 project has moved to the PyCQA organization on GitHub and will hopefully enjoy an expanded team of maintainers as a result. This comes after …

Posted on 11 July 2015 by Ian Cordasco

Cutting Off the Internet, Part I

This year I gave the talk "Cutting Off the Internet: Testing Applications that Use Requests" at PyTennessee and PyCon. The recording of the talk is already online with my slides.

At the end of my talk, I promised to write a blog post going into far more detail and covering …

Posted on 14 June 2015 by Ian Cordasco

Type Hints in Python 3.5

You may have already heard about this, but Guido van Rossum has co-authored PEP 484 [1] to standardize a basic set of Type Hints. If you've heard of PEP 484 already, this probably isn't the one-line summary you've heard about. In fact, if you've heard about this already, you've probably …

Posted on 24 April 2015 by Ian Cordasco

PyCon 2015 Recap

This year was my second year attending PyCon North America (a.k.a., PyCon US) and once again I loved every second of it.

tl;dr I didn't see a lot of talks in person but I spoke to a large number of people this year and made some great …
Posted on 13 April 2015 by Ian Cordasco

requests-toolbelt 0.4.0 released

It is my distinct pleasure to announce the 0.4.0 release of the requests toolbelt. This version comes almost a year after the release of 0.3.1.

A lot of work was put into the toolbelt in those 10 months though. We reorganized the documentation to make it …

Posted on 03 April 2015 by Ian Cordasco 1.0.0a1 released

On August 2nd, 2013 I opened issue 122 on's issue tracker. The driving force behind the "Roadmap for 1.0" was to clean up an API that I fundamentally disliked. Yesterday, on December 7th, 2014, I released the first alpha version of 1.0. The following is …

Posted on 08 December 2014 by Ian Cordasco

Retries in Requests

This is the second in what I hope will be a series of explorations of advanced features in requests.

Websites and servers sometimes, misbehave. They can misbehave in a number of ways:

  • read errors
  • large numbers of redirects
  • failure to connect
  • 500 errors

What most people don't know is that …

Posted on 01 December 2014 by Ian Cordasco

Sending JSON in Requests

This is the first in what I hope will be a series of explorations of advanced and lesser known features in requests.

Recently, the requests team released version 2.4.3. In this version, we had a very significant new feature released that was contributed by Carol Willing. It has …

Posted on 01 November 2014 by Ian Cordasco

Requests 1.2.0

tl;dr dispatch_hook now sends the keyword arguments that were originally sent with the request. Hook authors should modify their hooks to accept them and resend them.

This morning Kenneth published (on PyPI and Crate) requests 1.2.0 which included a lot of very important changes. One, which will …

Posted on 31 March 2013 by Ian Cordasco


I'm just going to collect some useful one-liners that I've either made myself or found elsewhere. I think some of these might benefit some people I know, so there may be follow up posts to add more.

What's my IP? (python)

This requires requests but it could probably be done …

Posted on 26 November 2012 by Ian Cordasco

Unittests in

After mostly finishing[1] I started writing the unittests for the library. I waited until the end because I knew I wanted to test directly against the API. To do that, I needed to make sure I had all the functionality that would return the proper objects to …

Posted on 18 September 2012 by Ian Cordasco

Weirdness in python2

So a friend of mine is learning python and was fooling around in the interactive console. They accidentally ran:

'str' > 19
# But they meant to run
'str' > '19'

Can you guess what that evaluated to? Conventional thought would suggest a TypeError, but in fact that evaluates to True. Odd right …

Posted on 22 August 2012 by Ian Cordasco

A Few Thoughts

I've just had a few things kicking around in my head lately and I thought I'd jot them down.

With the exception of paginated calls, is essentially feature complete but is lacking tests for everything. My plan as of this point in time is to finish …

Posted on 20 August 2012 by Ian Cordasco (update)

I previously mentioned my work on and how I was having trouble creating downloads on GitHub because they use Amazon's S3 service for the uploaded files. What this means is that first you have to "create" the download on GitHub then you have to upload the actual file …

Posted on 02 August 2012 by Ian Cordasco

Python: del

While testing by hand, I found myself wanted to delete objects that I created as a test from an array after deleting them on GitHub. To do that, I have to do:

del gists[index]

So my initial instinct was to modify the __del__ method …

Posted on 26 June 2012 by Ian Cordasco


I'm the kind of person who often fidgets with the appearance of the things I use. For example, over the course of a few weeks, I constantly changed the configuration file for wmii. I finally got it just right and haven't changed much since (except for the font). I've also …

Posted on 25 June 2012 by Ian Cordasco

After finishing finals, I started working on my project to wrap the Github API. Recently, I came across the area of the API dealing with creating a download on a repository. The one thing that has made this project so enjoyable has been requests. Upon reaching this section, I noticed …

Posted on 17 June 2012 by Ian Cordasco

The Context

I use on the rare occasion that I need to paste something for someone else to see. It's simple to use, written in python and open source. The chief example when you visit the website uses curl (and I love using the command line for as …

Posted on 09 June 2012 by Ian Stapleton Cordasco