GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing python-future.org — Standard library incompatibilities — Python-Future documentation Standard library incompatibilities¶Some standard library interfaces have changed in ways that require different code than normal Py3 code in order to achieve Py2/3 compatibility. Here we will attempt to document these, together with known workarounds:
To contribute to this list, please send a pull request. See Contributing. array.array()¶The first argument to
This means that the typecode cannot be specified portably across Python 3 and Python 2
with a single string literal when You can use the following code on both Python 3 and Python 2: from __future__ import unicode_literals from future.utils import bytes_to_native_str import array # ... a = array.array(bytes_to_native_str(b'b')) This was fixed in Python 2.7.11.
Since then, array.array.read()¶This method has been removed in Py3. This crops up in e.g. porting base64.decodebytes() and base64.encodebytes()¶The re.ASCII¶Python 3 code using regular expressions sometimes looks like this (from
re.compile(r":\d+$", re.ASCII) This enables ‘ASCII mode’ for regular expressions (see the docs here). Python 2’s
struct.pack()¶Before Python version 2.7.7, the >>> from __future__ import unicode_literals >>> from struct import pack >>> pack('<4H2I', version, rec_type, build, year, file_hist_flags, ver_can_read) raised This was fixed in Python 2.7.7.
Since then, | |||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |