IPython Documentation

Table Of Contents

Previous topic

Module: utils.process

Next topic

Module: utils.rlineimpl

This Page


This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: utils.py3compat

Compatibility tricks for Python 3. Mainly to do with unicode.

1 Class

class IPython.utils.py3compat.open(fname, mode='r', encoding='utf-8')

Bases: object

Wrapper providing key part of Python 3 open() interface.

__init__(fname, mode='r', encoding='utf-8')

11 Functions

IPython.utils.py3compat.no_code(x, encoding=None)
IPython.utils.py3compat.decode(s, encoding=None)
IPython.utils.py3compat.encode(u, encoding=None)
IPython.utils.py3compat.cast_unicode(s, encoding=None)
IPython.utils.py3compat.cast_bytes(s, encoding=None)

unicode(e) with various fallbacks. Used for exceptions, which may not be safe to call unicode() on.

IPython.utils.py3compat.isidentifier(s, dotted=False)
IPython.utils.py3compat.execfile(fname, *where)

“{u}’abc’” –> “u’abc’” (Python 2)

Accepts a string or a function, so it can be used as a decorator.

IPython.utils.py3compat.MethodType(func, instance)