functools.partial

functools.partial is one of those things that you don't need until you need it, and then you need it badly. Trying┬áto create a series of lambda functions I discovered that the simplest answer that came to my mind did something counter intuitive, and functools.partial - which I had ignored so far, came to my rescue. …

Advertisements

Common Lisp doesn’t yield (but it maps)

I didn't use Python's yield statement until I'd been programming for a few years. Within a few days of learning it, however, I could't live without it. I find Python generators and list/dict comprehensions one of the key things to making Python code compact and readable. I was pretty bummed to learn that Common Lisp …

__repr__()

I think repr() is Python's genius touch. What?! I'm sure you're yelling at the screen right now, incoherent as items from the long list of things you love about Python fight each other to get gain command of your voice. But it's what I think. And as you know, Lisp got there first. Now, of …

Chasing down a Cython error

My python program segfaulted. When I wrote C++ programs segfaults were no big deal. I would hook into gdb mostly through my IDE's debugger, and dance around the point the program crashed until I had an idea of where I was going wrong. Python gives a wonderful stack trace and tells you where things have …

While x:

This is a cautionary tale about not misusing Python's kindness. Or perhaps a cautionary tale about not trusting even widely used libraries to mirror what Python does. It is a little technical ... I have a program that, for the purposes of this post, operates on a list of pairs of numbers, going through each …