Changes between Version 10 and Version 11 of PortingNotesFor2To3


Ignore:
Timestamp:
Dec 25, 2011, 7:11:39 PM (13 years ago)
Author:
Vinay Sajip
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortingNotesFor2To3

    v10 v11  
    1212  replace `u'foo'` with `u('foo')` and `b'bar'` with `b('bar')` throughout the source.
    1313  The same applies to the constants with double quotes (`u"foo"` or `b"bar"`, which should be replaced by
    14   `u("foo")` or `b("bar")` respectively). '''Note:''' this is needed for Python 2.5 compatibility only. For compatibility only with Python 2.6 and later, add `from __future__ import unicode_literals` in all modules where you are using Unicode literals, and remove the `u` prefix from the Unicode literals, as you don't need it. If you need native strings, use `from django.utils.py3 import n` and replace those literals with n(...). This will return str on both 2.x and 3.x. If you need byte strings, use b'foo'.
     14  `u("foo")` or `b("bar")` respectively). '''Note:''' this is needed for Python 2.5 compatibility only. For compatibility only with Python 2.6 and later, add `from __future__ import unicode_literals` in all modules where you are using Unicode literals, and remove the `u` prefix from the Unicode literals, as you don't need it. If you need native strings, use `from django.utils.py3 import n` and replace those literals with `n(...)`. This will return `str` on both 2.x and 3.x. If you need byte strings, use `b'foo'`.
    1515
    1616* If you need to make any code conditional on 2.x vs. 3.x, you can do `from django.utils.py3 import PY3` and use `PY3`
Back to Top