On Sun, Feb 26, 2012 at 9:00 PM, Steven D'Aprano <steve at pearwood.info> wrote: > I think your suggestion is not well explained. You suggested a function n, > expected to take a string literal. The example you gave earlier was: > > n('xxx') > > But it seems to me that this is a no-op, because 'xxx' is already the native > string type. In Python 2, it gives a str (byte-string), which the n() > function converts to a byte-string. In Python 3, it gives a str > (unicode-string), which the n() function converts to a unicode-string. Vinay's suggestion was that it be used in conjunction with the "from __future__ import unicode_literals" import, so that you could write: b"" # Binary data "" # Text (unicode) data str("") # Native string type It reduces the problem (compared to omitting the import and using a u() function), but it's still ugly and still involves the "action at a distance" of the unicode literals import. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
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