[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

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Steven D'Aprano
On Wed, Mar 11, 2020 at 07:06:20PM +0200, Serhiy Storchaka wrote: > 11.03.20 12:39, Steven D'Aprano пише: > >https://bugs.python.org/issue35712 > > > >I am disappointed because, to me, it is a fundamental part of Python's > >object model that *everything* can be interpreted as a truthy/falsey >

[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

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Ethan Furman
On 03/11/2020 11:16 AM, Andrew Barnert via Python-ideas wrote: On Mar 11, 2020, at 02:42, Steve Jorgensen wrote: Take the following example: ``` def __lt__(self, other): return not self.__ge__(other): def __le__(self, other): return not self.__gt__(other): def

[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: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Andrew Barnert via Python-ideas
On Mar 11, 2020, at 02:42, Steve Jorgensen wrote: > > Take the following example: > > ``` >def __lt__(self, other): >return not self.__ge__(other): > >def __le__(self, other): >return not self.__gt__(other): > >def __ge__(self, other): > > ``` Usually you

[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

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Serhiy Storchaka
11.03.20 12:39, Steven D'Aprano пише: https://bugs.python.org/issue35712 I am disappointed because, to me, it is a fundamental part of Python's object model that *everything* can be interpreted as a truthy/falsey object (in the absence of bugs). NotImplemented is special. It is more special

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Guido van Rossum
Looks like NotImplemented is widely misunderstood. It should *ONLY* be returned from binary operator overloads, like __add__. On Wed, Mar 11, 2020 at 03:49 wrote: > Steven D'Aprano wrote: > > On Wed, Mar 11, 2020 at 09:42:15AM -, Steve Jorgensen wrote: > > > I realize this is probably

[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: More appropriate behavior for the NotImplemented object

2020-03-11 Thread jdveiga
Steven D'Aprano wrote: > On Wed, Mar 11, 2020 at 09:42:15AM -, Steve Jorgensen wrote: > > I realize this is probably something that would be > > hard to change for > > compatibility reasons. Maybe someone can think of a way around that > > though? > > It seems to me that not NotImplemented

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Steven D'Aprano
On Wed, Mar 11, 2020 at 09:42:15AM -, Steve Jorgensen wrote: > I realize this is probably something that would be hard to change for > compatibility reasons. Maybe someone can think of a way around that > though? > > It seems to me that `not NotImplemented` should result in >

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread jdveiga
Steve Jorgensen wrote: > I realize this is probably something that would be hard to change for > compatibility > reasons. Maybe someone can think of a way around that though? > It seems to me that not NotImplemented should result in > NotImplemented and attempting to convert it to bool should

[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

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread M.-A. Lemburg
NotImplemented is not supposed to be used in any operation. It's just a special value used in coercion since raising exceptions would be too costly. In your example you would need to check for this special value using the "is" comparison. See https://www.python.org/dev/peps/pep-0208/ and

[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

[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

[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

[Python-ideas] More appropriate behavior for the NotImplemented object

2020-03-11 Thread Steve Jorgensen
I realize this is probably something that would be hard to change for compatibility reasons. Maybe someone can think of a way around that though? It seems to me that `not NotImplemented` should result in `NotImplemented` and attempting to convert it to `bool` should raise a `TypeError`