Python Forum

Full Version: 'b' prefix, python 2 vs 3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I am making a suggestion to allow a no-op 'b' prefix for variables of type 'str' in python 2. Hopefully we can get this change in before python 2 is no longer supported.

Personally I make it a point to write code that is compatible with both python 2 and 3. This is very doable (even for the print statement as long as you only pass a single argument), but I still run into problem with open(..."b") and struct.pack in python 3 because of the new byte types. It would be great if I could write python 3 code with the 'b' prefix that also worked in python 2 (at least not crash from the syntax error).

Thanks!
I just tested version 2.7.15 and found that your "suggestion" is already the case.

Also, we're not officially linked to the Python Software Foundation, so no one who matters for that kind of thing will see this post. They have mailing lists where you'd be more likely to be seen.