ipython/ipython — pull request #1526 by takluyver (2012-03-25 22:05:00+00:00)
Title: Find encoding for Python files

As I promised some time ago, this uses the encoding cookie defined in PEP 263 to correctly decode .py files in encodings other than utf-8.

Most of the code is borrowed from Python 3.2's `tokenize` module, but there are some additions.

Try, for example `%loadpy https://raw.github.com/python-excel/xlrd/master/xlrd/examples/xlrdnameAPIdemo.py` (encoded in cp1252).