[Python-ideas] Python 3000 TIOBE -3%

Stephen J. Turnbull stephen at xemacs.org
Mon Feb 13 05:50:04 CET 2012

Masklinn writes:

 > Why not open the file in binary mode in stead? (and replace `'*'`
 > by `b'*'` in the startswith call)

This will often work, but it's task-dependent.  In particular, I
believe not just `.startswith(), but general regexps work with either
bytes or str in Python 3.  But other APIs may not. and you're going to
need to prefix *all* literals (including those in modules your code
imports!) with `b`.  So you import a module that does exactly what you
want, and be stymied by a TypeError because the module wants Unicode.

This would not happen with Python 2, and there's the rub.

More information about the Python-ideas mailing list