New Exception Hierarchy In Python 3.3+

Working with the new stable version of Python 3.3, I stumbled upon the new exception hierarchy. Specifically, I was working on some file-related routines and found in the release notes, that for this domain a new set of exceptions is introduced and that IOError is now OSError.

Things are ...

more ...

Copying Data Structures Quirks

Note

TL;DR — Copying fails if a value is an iterator.

To create a duplicate of a data structure, Python provides methods copy() and deepcopy(). Lately, I wanted to duplicate a nested structure with deepcopy() and encountered following issue:

TypeError: object.__new__(dict_keys) is not safe, use dict_keys.__new__()

And ...

more ...

Python 3 Unicode-Bytes Quirks

Imagine in your program you compare two variables which contain strings. You are pretty sure that under certain circumstances both variables contain the same strings, — but somehow Python insists that they do not!

For a quick debug, you print out both variables and get

>>> print(s1, s2, s1 == s2)
b ...
more ...

Porting feedgenerator to Py3k

Actually, here we already are some steps into my efforts to port Pelican [2] to Python 3, — I’ll write about the beginning steps later, promise. (Here is a first impression [3])

Feedgenerator 1.2.1 is a stand-alone version of a Django module with that name. During the port ...

more ...