[Ironpython-users] binary strings in 2.7.2 alpha?

Dino Viehland dinov at microsoft.com
Sat Feb 4 02:13:58 CET 2012


This is back to the unicode vs str difference. In addition to Unicode and str being the same starting with IronPython 2.6 we added the bytes type (matching the alias of bytes -> str that CPython added) and made the b'' syntax construct a bytes object.  The bytes type works like CPython 2.x's str type.

In general when it comes to strings IronPython is like Python 3.x.  But there's still some small differences, like indexing into bytes works like CPython 2.x returning a single-char string instead of the ordinal value like Python 3.x.

Unfortunately this is IronPython's biggest compatibility minefield :(

From: ironpython-users-bounces+dinov=microsoft.com at python.org [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org] On Behalf Of Daniel Fernandez
Sent: Friday, February 03, 2012 5:01 PM
To: ironpython-users at python.org
Subject: [Ironpython-users] binary strings in 2.7.2 alpha?

Hi All,

I'm playing with open source package  and I am getting an error with prefix "b" with a string literal with expected str and got bytes. Here is a simple example, IronPython 2.7.2 alpha I get the following

>>> type(b"/")
<type 'bytes'>

In CPython 2.7.2 I get the following

>>> type(b"/")
<type 'str'>

I searched for more information on this but I didn't find alot on it. I did find one site indicating that this is a python 3.0 feature, I just wanted to confirm.

Thanks.

Danny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120204/ad41edbb/attachment.html>


More information about the Ironpython-users mailing list