Python 3.x Gotchas

Python continues to improve with plenty of new features and improvements with each release. When working with older versions of Python 3.x it’s easy to forget how new some features are.

Beware pathlib on 3.5

While pathlib exists in Python 3.5, it’s not fully integrated yet. Passing a pathlib.Path object to the built-in open() method will result in a surprising error

TypeError: invalid file: PosixPath('path/to/file.txt')

In this situation it’s better to call the path’s open() method instead.