Articles in the python category

Preserve Your Sanity When Dealing with Unicode in Python

I have not yet played with python 3, which sounds like it makes working with Unicode easier.

In python 2.x, working with Unicode can be annoying, but when you remember this rule of thumb, it's much easier and allows you to keep your sanity:

Always use unicode strings ...

Use Linux to build win32 installers for Python apps

A python-based project I'm working on has a win32 user that I need to support. Until yesterday I've been moving to a win32 laptop in order to run python bdist_wininst so I can produce a self-installing executable. Then I discovered how trivial it is to use ...

3 Easy Ways to Stick to a Coding Standard

When you're writing python, you don't need a lot of debate over the minutiƦ of most coding standards. PEP 8 does that for you. Even better, there are some tools that make it really easy to stick to the standard.

Why do this? Well, for one thing it ...

Using Python's ctypes to Call Into C Libraries

The ctypes module makes loading and calling into a dynamic library incredibly easy:

>>> from ctypes import CDLL
>>> libc = CDLL('')
>>> print libc.strlen('abcde')

As with everything else in python, it gets even better when you scratch the surface. In the example above, CDLL returns an object ...

Yet Another Python Enum Module

I didn't like the existing enum recipes, so I cooked up what I feel is a better way of working with enumerations in python. The result is yapyenum, hosted on github. Rather than come up with something new to say about it, I'll just repost the README here ...

Python Exception Handling: Cleanup and Reraise

I've had this code around for a while and had an opportunity to drag it out the other day and dust it off. The problem: Every now and again there's a situation where you don't really want to catch an exception, but you do want to perform ...

Page 1 / 1