[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-03-03 Thread M.-A. Lemburg
The main reason for having not having characters and strings is reducing complexity. Why try to add this now for no apparent net benefit ? I think the situation with bytes (iteration returning integers instead of bytes) has shown that this not a very user friendly nor intuitive approach: >>> b =

[Python-ideas] Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
I have encountered cases in which I would like to validate that an argument can be properly compared with other instances of its type. This is true of numbers, strings, dates, … but not for `NoneClass`, `type`, …. One way that I have tried to handle this is to check whether the object can be co

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Guido van Rossum
I think it’s usually called Orderable. It’s a useful concept in static type checking too (e.g. mypy), where we’d use it as an upper bound for type variables, if we had it. I guess to exclude sets you’d have to introduce TotalOrderable. On Tue, Mar 3, 2020 at 04:03 Steve Jorgensen wrote: > I have

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-03-03 Thread Andrew Barnert via Python-ideas
On Mar 3, 2020, at 01:09, M.-A. Lemburg wrote: > > The main reason for having not having characters and strings is > reducing complexity. Why try to add this now for no apparent > net benefit ? I don’t think the benefit is worth the (as far as I can tell insurmountable) backward compatibility

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
Guido van Rossum wrote: > I think it’s usually called Orderable. It’s a useful concept in static type > checking too (e.g. mypy), where we’d use it as an upper bound for type > variables, if we had it. I guess to exclude sets you’d have to introduce > TotalOrderable. > On Tue, Mar 3, 2020 at 04:03

[Python-ideas] Re: None should raise a new exception, NoneError

2020-03-03 Thread Christopher Barker
On Mon, Mar 2, 2020 at 7:12 PM Guido van Rossum wrote: > Anyone can define their own singleton easily enough. > Sure, though there is far more utility in having a standard way to do standard things. But if anyone really thinks this is important, making a new Singleton that behaves the way you w

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Guido van Rossum
On Tue, Mar 3, 2020 at 10:43 AM Steve Jorgensen wrote: > Guido van Rossum wrote: > > I think it’s usually called Orderable. It’s a useful concept in static > type > > checking too (e.g. mypy), where we’d use it as an upper bound for type > > variables, if we had it. I guess to exclude sets you’d

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread David Mertz
On Tue, Mar 3, 2020 at 5:35 PM Guido van Rossum wrote: > But beware, IIRC there are pathological cases involving floats, (long) > ints and rounding where transitivity may be violated in Python (though I > believe only Tim Peters can produce an example :-). I'm honestly not sure > that that's enou

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
Guido van Rossum wrote: > On Tue, Mar 3, 2020 at 10:43 AM Steve Jorgensen [email protected] wrote: > > Guido van Rossum wrote: > > I think it’s usually called Orderable. It’s a > > useful concept in static > > type > > checking too (e.g. mypy), where we’d use it as an upper bound for type > > vari

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Tim Peters
[Guido] > But beware, IIRC there are pathological cases involving floats, (long) ints > and rounding where transitivity may be violated in Python (though I believe > only Tim Peters can produce an example :-). Not anymore ;-) That is, while comparisons mixing bigints and floats may have suffered

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread MRAB
On 2020-03-04 00:58, Tim Peters wrote: [Guido] But beware, IIRC there are pathological cases involving floats, (long) ints and rounding where transitivity may be violated in Python (though I believe only Tim Peters can produce an example :-). Not anymore ;-) That is, while comparisons mixing

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Greg Ewing
On 4/03/20 7:42 am, Steve Jorgensen wrote: That's a much better term. `Orderable` and `ProtoOrderable`. I would suggest "TotallyOrdered" and "PartiallyOrdered". -- Greg ___ Python-ideas mailing list -- [email protected] To unsubscribe send an e

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
Greg Ewing wrote: > On 4/03/20 7:42 am, Steve Jorgensen wrote: > > That's a much better term. Orderable and > > ProtoOrderable. > > I would suggest "TotallyOrdered" and "PartiallyOrdered". Possibly, but the reasoning is not obvious to me. Can you explain? I get that `TotallyOrdered` is consisten

[Python-ideas] Exception for parameter errors

2020-03-03 Thread Steven D'Aprano
At the moment, when you call a function, if there is any mismatch between the function parameters and the supplied arguments, TypeError is raised. For example: # Too few arguments len() # Too many arguments ord('a', 'b') # Invalid keywords min([], func=len) etc. (There

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Chris Angelico
On Wed, Mar 4, 2020 at 6:04 PM Steve Jorgensen wrote: > > Greg Ewing wrote: > > On 4/03/20 7:42 am, Steve Jorgensen wrote: > > > That's a much better term. Orderable and > > > ProtoOrderable. > > > I would suggest "TotallyOrdered" and "PartiallyOrdered". > > Possibly, but the reasoning is not obvi

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
Chris Angelico wrote: > On Wed, Mar 4, 2020 at 6:04 PM Steve Jorgensen [email protected] wrote: > https://en.wikipedia.org/wiki/Partially_ordered_set > "Partially ordered" means you can compare pairs of elements and find > which one comes first. "Totally ordered" means you can compare ANY > pair

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Steve Jorgensen
Steve Jorgensen wrote: > Chris Angelico wrote: > > On Wed, Mar 4, 2020 at 6:04 PM Steve Jorgensen > > [email protected] wrote: > > > > https://en.wikipedia.org/wiki/Partially_ordered_set > > "Partially ordered" means you can compare pairs of elements and find > > which one comes first. "Totally

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Alex Hall
On Wed, Mar 4, 2020 at 9:26 AM Steve Jorgensen wrote: > Chris Angelico wrote: > > On Wed, Mar 4, 2020 at 6:04 PM Steve Jorgensen [email protected] wrote: > > > https://en.wikipedia.org/wiki/Partially_ordered_set > > "Partially ordered" means you can compare pairs of elements and find > > which

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-03 Thread Stéfane Fermigier
On Wed, Mar 4, 2020 at 8:24 AM Steve Jorgensen wrote: > Chris Angelico wrote: > > On Wed, Mar 4, 2020 at 6:04 PM Steve Jorgensen [email protected] wrote: > > > https://en.wikipedia.org/wiki/Partially_ordered_set > > "Partially ordered" means you can compare pairs of elements and find > > which