Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197868

Re: open: 'ascii', 'backslashreplace' not behaving as expected - why?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Veek M <veekjunk@foobar.com>
Newsgroups comp.lang.python
Subject Re: open: 'ascii', 'backslashreplace' not behaving as expected - why?
Date Sat, 8 Aug 2026 04:22:59 -0000 (UTC)
Organization A noiseless patient Spider
Lines 11
Message-ID <1156av3$15v7o$1@dont-email.me> (permalink)
References <1155tpv$13on7$1@dont-email.me> <1156074$14bmn$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Sat, 08 Aug 2026 04:23:01 +0000 (UTC)
Injection-Info dont-email.me; logging-data="1244408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YQI80tKOVwJZP++KBvqOM"; posting-host="d75c4908dd89aa0bd2d1c9efc307aee7"
User-Agent Pan/0.154 (Izium; 517acf4)
Cancel-Lock sha1:KlJbCln5MPAPwl1vebm0+P8VfOM= sha256:TZjMFh392Iu2BWQ9wl+1wuUytxsWervjOQ2iPn5ddCE= sha1:lbNwAlYvSyY9LniA2OH4zS6Pejc= sha256:ofVt/syMm6ttPXHAB8EirBmAeiUcFnp+wJAjv8yvw4c=
Xref csiph.com comp.lang.python:197868

Show key headers only | View raw


On Sat, 8 Aug 2026 01:19:32 -0000 (UTC), Lawrence D’Oliveiro wrote:

> b'\xef\xbf\xbf\n'.decode()

Could you explain how it works and what exactly is going on?

fh.readline() returns a unicode string with the funny chars (bytes 0xff 
0xff) encoded as \\xef \\xbf \\xbf - why is it \\? why not just use a 
single u'\xef\xbf\xbf' - why is he escaping the '\'.

Also - how exactly is he getting ef bf bf and not ff ff?

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 00:38 +0000
  Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-08 01:19 +0000
    Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:22 +0000
      Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:25 +0000
        Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:33 +0000
          Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Greg Ewing <greg.ewing@canterbury.ac.nz> - 2026-08-10 12:08 +1200

csiph-web