[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Christopher Barker
On Wed, Mar 11, 2020 at 6:59 AM Rhodri James wrote: > I disagree. We've headed off down the rabbit-hole of filenames for > justification here, but surely pathlib is the correct tool if you are > going to be chopping up filenames and path names? Does pathlib work correctly for paths in unknown

[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Barry Scott
> On 11 Mar 2020, at 19:03, Rhodri James wrote: > > On 11/03/2020 18:45, Stephen J. Turnbull wrote: >> Rhodri James writes: >> > We've headed off down the rabbit-hole of filenames for >> > justification here, but surely pathlib is the correct tool if you >> > are going to be chopping up fil

[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Rhodri James
On 11/03/2020 18:45, Stephen J. Turnbull wrote: Rhodri James writes: > We've headed off down the rabbit-hole of filenames for > justification here, but surely pathlib is the correct tool if you > are going to be chopping up filenames and path names? This isn't obvious to me. The majority

[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Stephen J. Turnbull
Rhodri James writes: > We've headed off down the rabbit-hole of filenames for > justification here, but surely pathlib is the correct tool if you > are going to be chopping up filenames and path names? This isn't obvious to me. The majority of people (among those for whom my respect is "very

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Andrew Barnert via Python-ideas
On Mar 11, 2020, at 03:07, Steven D'Aprano wrote: > > But bytes are useful for more than just file names! The paradigm example of this is HTTP. It’s mostly people working on HTTP clients, servers, middleware, and apps who pushed for the bytes methods in Python 3.x. IIRC, the PEP for bytes.__mo

[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Rhodri James
On 10/03/2020 20:18, Christopher Barker wrote: ...much about file naming in theory and practice under Unix, concluding with: But bytes has a pretty full set of "string like" methods now, so I suppose it makes sense to add a couple new ones that are related to ones that are already there. I

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Chris Angelico
On Wed, Mar 11, 2020 at 9:28 PM Steven D'Aprano wrote: > > On Wed, Mar 11, 2020 at 07:28:06AM +1100, Chris Angelico wrote: > > > That's exactly what "ASCII compatible" means. Since ASCII is a > > seven-bit encoding, an encoding is ASCII-compatible if (a) every ASCII > > character is represented by

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Chris Angelico
On Wed, Mar 11, 2020 at 9:05 PM Steven D'Aprano wrote: > In practice, modern Unix shells and GUIs use UTF-8. UTF-8 has two nice > properties: > > * Every ASCII character encodes to a single byte, so text which > only contains ASCII values encodes to precisely the same set > of bytes under UTF-

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Steven D'Aprano
On Wed, Mar 11, 2020 at 07:28:06AM +1100, Chris Angelico wrote: > That's exactly what "ASCII compatible" means. Since ASCII is a > seven-bit encoding, an encoding is ASCII-compatible if (a) every ASCII > character is represented by the corresponding byte value, and (b) > every seven-bit value repr

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Steven D'Aprano
Christopher, I'm not sure how much of the following you already know, so excuse me in advance if I'm covering old ground for you. But hopefully it will be helpful for someone! On Tue, Mar 10, 2020 at 01:18:22PM -0700, Christopher Barker wrote: > Getting a bit OT, but I *think* this is the story

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Andrew Barnert via Python-ideas
On Mar 10, 2020, at 13:18, Christopher Barker wrote: > > Getting a bit OT, but I *think* this is the story: > > I've heard it argued, by folks that want to write Python software that uses > bytes for filenames, that: > > A file path on a *nix system can be any string of bytes, except two speci

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Chris Angelico
On Wed, Mar 11, 2020 at 7:19 AM Christopher Barker wrote: > > Getting a bit OT, but I *think* this is the story: > > I've heard it argued, by folks that want to write Python software that uses > bytes for filenames, that: > > A file path on a *nix system can be any string of bytes, except two spe

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Christopher Barker
Getting a bit OT, but I *think* this is the story: I've heard it argued, by folks that want to write Python software that uses bytes for filenames, that: A file path on a *nix system can be any string of bytes, except two special values: b'\x00' : null b'\x2f': slash (consistent with this

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Andrew Barnert via Python-ideas
On Mar 10, 2020, at 08:01, David Mertz wrote: >> Most real-world UNIX systems only support ASCII-compatible encodings. >> There's no reason not to solve the problem on such systems by using >> os.fsdecode(). > > Huh?! > > Is my Ubuntu derivative not "real world"? > > 666-tmp % uname -a > Linu

[Python-ideas] Re: prefix/suffix for bytes

2020-03-10 Thread Rhodri James
On 10/03/2020 14:58, David Mertz wrote: Most real-world UNIX systems only support ASCII-compatible encodings. There's no reason not to solve the problem on such systems by using os.fsdecode(). Huh?! Is my Ubuntu derivative not "real world"? 666-tmp % uname -a Linux popkdm 5.3.0-7629-generic

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread David Mertz
> Most real-world UNIX systems only support ASCII-compatible encodings. > There's no reason not to solve the problem on such systems by using > os.fsdecode(). > Huh?! Is my Ubuntu derivative not "real world"? 666-tmp % uname -a Linux popkdm 5.3.0-7629-generic #31~1581628825~19.10~f90b7d5-Ubuntu

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Random832
On Sat, Mar 7, 2020, at 19:31, Cameron Simpson wrote: > >I *think* I understand the issues. And I can see that some software would > >need to work with filenames as arbitrary bytes. But that doesn't mean that > >you can do much with them that way. > > Given that the entire UNIX filename API is byt