[Python-Dev] Py3k bytes type in 2.x (Re: nonlocal keyword in 2.x?)
mal at egenix.com
Thu Nov 5 11:56:28 CET 2009
Nick Coghlan wrote:
> M.-A. Lemburg wrote:
>> Nick Coghlan wrote:
>>> Lennart Regebro wrote:
>>>> I also would really like to see a real port of the bytes class to 2.6,
>>>> but I have a vague memory that there was some reason that wouldn't
>>> Not so much that it wouldn't work, but that the interfaces to support
>>> using it effectively really aren't there - lots of areas in the standard
>>> library needed to be tweaked to cope with bytes objects in 3.x.
>>> Generally speaking, the "bytes = str" trick represents a reasonable
>>> compromise as the APIs that you would pass a bytes object to in 3.x
>>> expect an 8-bit str instance in 2.x.
>> Could you please add such hints, tricks and tips to the wiki
> Done (although the task of figuring out how to get the wiki to display
> code properly defeated me... the normal Python documentation syntax for
> it seemed to give the wiki's ReST interpreter fits).
> I also mentioned the trick someone mentioned about "from __future__
> import unicode_literals" not changing the meaning of 'str' since it only
> alters the parser but not the builtins.
> In writing it up, it occurred to me that having that kind of thing in a
> "py3_compat" compatibility module (to be used as, e.g., "from py3_compat
> import str, bytes") would not only make it easier to use in multiple
> modules, but also easier for 2to3 to remove when forward porting.
That would certainly be useful to have, yes, since all
developers wanting to support both 2.7 and 3.2 using the same
code base will have a need for these things.
It would also help to have a package that contains proxy modules
using the Python 3.x module/package names which map the functionality
back to the Python 2.x modules.
This avoids problems with freezing tools that scan the source
code for imports as well as pickles which store the full
dotted path name to classes.
Professional Python Services directly from the Source (#1, Nov 05 2009)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-Dev