atelier.utils

Defines a series of utility classes and functions.

(This module’s source code is available here.)

Functions

dict_py2(old_dict)

Convert the given dict so that it’s repr is the same for both Python 2 and 3.

list_py2(old_list)

Convert the given list so that it’s repr is the same for both Python 2 and 3.

rmu(x)

Remove the ‘u’ prefix from unicode strings under Python 2 in order to produce Python 3 compatible output in a doctested code snippet.

sixprint(*args)

Like print, but simulating PY3 output under PY2.

tuple_py2(old_tuple)

Convert the given tuple so that it’s repr is the same for both Python 2 and 3.

atelier.utils.dict_py2(old_dict)

Convert the given dict so that it’s repr is the same for both Python 2 and 3.

Deprecated. Use rmu() instead.

atelier.utils.list_py2(old_list)

Convert the given list so that it’s repr is the same for both Python 2 and 3.

Deprecated. Use rmu() instead.

atelier.utils.tuple_py2(old_tuple)

Convert the given tuple so that it’s repr is the same for both Python 2 and 3.

Deprecated. Use rmu() instead.

atelier.utils.rmu(x)

Remove the ‘u’ prefix from unicode strings under Python 2 in order to produce Python 3 compatible output in a doctested code snippet.

>>> lst = [123, "123", u"Äöü"]
>>> print(rmu(lst))
[123, '123', '\xc4\xf6\xfc']
>>> print(rmu(tuple(lst)))
(123, '123', '\xc4\xf6\xfc')
>>> dct = {i: i for i in lst}
>>> print(rmu(dct)) 
{...'\xc4\xf6\xfc': '\xc4\xf6\xfc'...}
atelier.utils.sixprint(*args)

Like print, but simulating PY3 output under PY2.