<div class="gmail_quote">2011/1/1 Stefan Behnel <span dir="ltr"><<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Terry Reedy, 01.01.2011 11:08:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a way to mark string literals so that 2to3 automatically<br>
prefixes them with 'b'? Is there a simpler trick?<br>
</blockquote>
<br>
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit<br>
(Intel)] on win32<br>
Type "copyright", "credits" or "license()" for more information.<br>
 >>> b=b'abc'<br>
 >>> b<br>
'abc'<br>
<br>
The b prefix does nothing in 2.7. It was specifically added for this type<br>
of porting problem.<br>
</blockquote>
<br></div>
More precisely, it was added in Python 2.6, so older Python versions will consider it a syntax error.<br>
<br>
To support older Python versions, you need to write your own wrapper functions for bytes literals that do nothing in Python 2 and convert the literal back to a bytes literal in Python 3. That's ugly, but there's no other way to do it.<br>

</blockquote><div><br></div><div>Thanks, I'll go that way. I guess it is an area where 3to2 would be better...</div><div><br></div></div>