← Back to DAGDA | Support | Source: https://mail.python.org/pipermail/python-porting/2010-June/000142.html

[Python-porting] [ANN] Six, utilities for supporting Python 2 and 3 with the same code base

Lennart Regebro regebro at gmail.com
Wed Jun 30 22:32:49 CEST 2010


On Wed, Jun 30, 2010 at 21:18, Brett Cannon <brett at python.org> wrote:
> I was actually thinking about doing this; you beat me to it! =)

Me three! :-)

I haven't looked at the code yet, just the docs. I have a suggestion
for an addition, my bites-class. It's a subclass for bytes or str
(depending on Python version) that enables you to do slicing of binary
data with the same API both under Python 2 and Python 3. Like so:

>>> from bites import Bites
>>> data = Bites(open("thefile", 'rb').read())
>>> data.itemint(3)
75
>>> [x for x in data]
32, 45, 112, 75, 30

Otherwise you'll get characters under Python 2 and integers under Python 3.

I attached it, feel free to add it if you like.

-- 
Lennart Regebro: http://regebro.wordpress.com/
Python 3 Porting: http://python3porting.com/
+33 661 58 14 64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bites.py
Type: text/x-python
Size: 859 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-porting/attachments/20100630/37112f36/attachment.py>


More information about the Python-porting mailing list