diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-11 15:34:51 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-12 14:44:40 +0200 |
| commit | a0a0203a392f67832ba7a8a2f099e70d7db2d19e (patch) | |
| tree | 719ede41d6dfc5a6d78b57d3a6e53cc97952cc13 /docs | |
| parent | e7e08fd48b3f88d4eb481f5b213b923fc1db3675 (diff) | |
[py3] Added python_2_unicode_compatible decorator.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/utils.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index b6cb1035d3..97643c29e9 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -187,6 +187,14 @@ The functions defined in this module share the following properties: Useful as a mix-in. If you support Python 2 and 3 with a single code base, you can inherit this mix-in and just define ``__unicode__``. +.. function:: python_2_unicode_compatible + + A decorator that defines ``__unicode__`` and ``__str__`` methods under + Python 2. Under Python 3 it does nothing. + + To support Python 2 and 3 with a single code base, define a ``__str__`` + method returning text and apply this decorator to the class. + .. function:: smart_text(s, encoding='utf-8', strings_only=False, errors='strict') .. versionadded:: 1.5 |
