A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-January/131361.html below:

[Python-Dev] PEP 460 reboot

[Python-Dev] PEP 460 reboot [Python-Dev] PEP 460 rebootGuido van Rossum guido at python.org
Mon Jan 13 04:45:13 CET 2014
On Sun, Jan 12, 2014 at 6:16 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> In reference to a byte stream, if you do:
>
> --> b'%s' % 'some text'.encode('cp1241')
>
> it's really just bytes into bytes.

That's a confusing example -- it would be clearer to just show

b'%s' % b'some text'

> If you do :
>
> --> b'%s' % 'some text'
>
> then the encoding is ASCII with strict error checking.  So if it's not
> representable as clean ASCII either encode it manually, or prepare for it to
> blow up with an UnicodeEncodeError.

You don't say what outcome you want, but if you wanted b'%s' % 'some
text' to return b'some text' while b'%s' % '\u1234' should blow up,
you're back at the Python 2 approach and that is the last thing I
want.

-- 
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev mailing list

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