A backport of the get_terminal_size function from Python 3.3's shutil.
Unlike the original version it is written in pure Python rather than C, so it might be a tiny bit slower.
>>> from backports.shutil_get_terminal_size import get_terminal_size
>>> get_terminal_size()
terminal_size(columns=105, lines=33)