On Wed, Jun 23, 2010 at 6:09 AM, M.-A. Lemburg <mal at egenix.com> wrote: >> return constant.encode('utf-8') >> >> So now you can write x.split(literal_as('&', x)). > > This polymorphism is what we used in Python2 a lot to write > code that works for both Unicode and 8-bit strings. > > Unfortunately, this no longer works as easily in Python3 due > to the literals sometimes having the wrong type and using > such a helper function slows things down a lot. I didn't work in 2 either - see for instance the traceback module with an Exception with unicode args and a non-ascii file path - the file path is in its bytes form, the string joining logic triggers an implicit upcast and *boom*. > Too bad we can't add such porting enhancements to Python2 anymore Perhaps a 'py3compat' module on pypi, with things like the py._builtin reraise helper and so forth ? -Rob
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4