### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# 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)

`IPython.utils.py3compat.``safe_unicode`(e)

  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)

`IPython.utils.py3compat.``doctest_refactor_print`(func_or_str)

`IPython.utils.py3compat.``u_format`(func_or_str)

  “{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)

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »