Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-20 Thread Terry Reedy
On 2/20/2018 12:06 PM, Guido van Rossum wrote: Looking at https://en.wikipedia.org/wiki/Number it seems that Integer is "special" -- every other number type is listed as " numbers" (e.g. rational numbers, complex numbers) but integers are listed as "Integers". So let's just switch it to that,

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-20 Thread Greg Ewing
On Mon, Feb 19, 2018 at 5:58 AM, Sylvain MARIE > wrote: By the way, is there a reason for the name "Integral" (algebraic theory) instead of "Integer" (computer science) ? Would it be practically

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-20 Thread Sylvain MARIE
 : Sylvain MARIE <sylvain.ma...@schneider-electric.com>; Python-Ideas <python-ideas@python.org> Objet : Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module Guido van Rossum writes: > Hm, perhaps Integral is an adjective, just like Boolean? I

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-20 Thread Guido van Rossum
Looking at https://en.wikipedia.org/wiki/Number it seems that Integer is "special" -- every other number type is listed as " numbers" (e.g. rational numbers, complex numbers) but integers are listed as "Integers". So let's just switch it to that, and keep Integral as an alias for backwards

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-19 Thread Stephen J. Turnbull
Guido van Rossum writes: > Hm, perhaps Integral is an adjective, just like Boolean? I would guess so. This is the same idiom we use when we call [1, 2, 3] a "truth-y". ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-19 Thread Nick Coghlan
On 20 February 2018 at 08:33, Guido van Rossum wrote: > Hm, perhaps Integral is an adjective, just like Boolean? Though it's also > possible that it was simply a mistake. In general I don't like adding > aliases for different spellings -- it violates TOOWTDI. If we decide that >

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-19 Thread Guido van Rossum
On Mon, Feb 19, 2018 at 5:58 AM, Sylvain MARIE < sylvain.ma...@schneider-electric.com> wrote: > > A thought just occurred to me. Maybe we should just add a Boolean class > to numbers? > > That would be great indeed > > > It's a subclass of Integral, presumably. And normally only builtins.bool >

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-19 Thread Serhiy Storchaka
15.02.18 18:27, Guido van Rossum пише: A thought just occurred to me. Maybe we should just add a Boolean class to numbers? It's a subclass of Integral, presumably. Isn't bool a subclass of int only for historical reasons? I think that if bool was in Python from the beginning, it would not be

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-19 Thread Sylvain MARIE
vendredi 16 février 2018 22:42 À : gu...@python.org Cc : Sylvain MARIE <sylvain.ma...@schneider-electric.com>; Python-Ideas <python-ideas@python.org> Objet : Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module Sent from my iPhone > A thought just

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-16 Thread Chris Barker - NOAA Federal
Sent from my iPhone > A thought just occurred to me. Maybe we should just add a Boolean class to > numbers? This makes lots of sense to me. Bool is a subclass of int — might as well embrace that fact. -CHB ___ Python-ideas mailing list

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-15 Thread Guido van Rossum
> *De :* Guido van Rossum [mailto:gvanros...@gmail.com] > *Envoyé :* mercredi 14 février 2018 17:14 > *À :* Sylvain MARIE <sylvain.ma...@schneider-electric.com> > *Cc :* Python-Ideas <python-ideas@python.org> > > *Objet :* Re: [Python-ideas] Boolean ABC similar to what's pr

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Guido van Rossum
On Wed, Feb 14, 2018 at 5:49 PM, Chris Barker - NOAA Federal < chris.bar...@noaa.gov> wrote: > > > > So as long as you are not expecting to ever need mypy you should be fine > -- however if you're sharing code at some point someone is probably going > to want to point mypy at it. > > mypy isn’t

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Chris Barker - NOAA Federal
> > So as long as you are not expecting to ever need mypy you should be fine -- > however if you're sharing code at some point someone is probably going to > want to point mypy at it. mypy isn’t an “official” tool, but PEP484 is — and mypy is more or less a reference implimentation, yes? mypy

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Guido van Rossum
type hinting is also the use case for which I make extensive use > of the types from the ‘numbers’ package, for the same reasons. > > > > Sylvain > > > > *De :* Python-ideas [mailto:python-ideas-bounces+sylvain.marie=schneider- > electric@python.org] *De la part d

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Sylvain MARIE
Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module I am mystified how you can be using the numbers package with mypy. Example: import numbers def f(a: numbers.Integral, b: numbers.Integral) -> numbers.Integral: return a + b f(12, 12) This gives an two errors on the

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Guido van Rossum
ain.marie=schneider- > electric@python.org] *De la part de* David Mertz > *Envoyé :* mardi 13 février 2018 07:08 > *À :* Nick Coghlan <ncogh...@gmail.com> > *Cc :* python-ideas <python-ideas@python.org> > *Objet :* Re: [Python-ideas] Boolean ABC similar to what's provide

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Sylvain MARIE
: Nick Coghlan <ncogh...@gmail.com> Cc : python-ideas <python-ideas@python.org> Objet : Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module I'm not sure I'm convinced by Sylvain that Boolean needs to be an ABC in the standard library; Guido expresse

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Guido van Rossum
es+sylvain.marie=schneider- electric@python.org] *De la part de* Chris Barker *Envoyé :* mardi 13 février 2018 21:12 *À :* David Mertz <me...@gnosis.cx> *Cc :* python-ideas <python-ideas@python.org> *Objet :* Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers'

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-14 Thread Sylvain MARIE
de Chris Barker Envoyé : mardi 13 février 2018 21:12 À : David Mertz <me...@gnosis.cx> Cc : python-ideas <python-ideas@python.org> Objet : Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module On Mon, Feb 12, 2018 at 10:07 PM, David Mertz <me...@gnos

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-13 Thread Chris Barker
On Mon, Feb 12, 2018 at 10:07 PM, David Mertz wrote: > I'm not sure I'm convinced by Sylvain that Boolean needs to be an ABC in > the standard library; Guido expresses skepticism. Of course it is possible > to define it in some other library that actually needs to use >

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread David Mertz
I'm not sure I'm convinced by Sylvain that Boolean needs to be an ABC in the standard library; Guido expresses skepticism. Of course it is possible to define it in some other library that actually needs to use `isinstance(x, Boolean)` as Sylvain demonstraits in his post. I'm not sure I'm

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread Nick Coghlan
On 13 February 2018 at 02:14, David Mertz wrote: > NumPy np.bool_ is specifically not a subclass of any np.int_. If it we're, > there would be an ambiguity between indexing with a Boolean array and an > array of ints. Both are meaningful, but they mean different things (mask vs

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread David Mertz
NumPy np.bool_ is specifically not a subclass of any np.int_. If it we're, there would be an ambiguity between indexing with a Boolean array and an array of ints. Both are meaningful, but they mean different things (mask vs collection of indices). Do we have other examples a Python ABC that

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread Guido van Rossum
TBH I've found the numeric tower a questionable addition to Python's stdlib. For PEP 484 we decided not to use it (using the concrete types, int, float etc. instead). So I'm not excited about adding more like this, especially since essentially *everything* can be used in a Boolean context. If

Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread Steven D'Aprano
On Mon, Feb 12, 2018 at 09:41:04AM +, Sylvain MARIE wrote: > The numbers module provides very useful ABC for the 'numeric tower', > able to abstract away the differences between python primitives and > for example numpy primitives. > I could not find any equivalent for Booleans. > However

[Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-12 Thread Sylvain MARIE
The numbers module provides very useful ABC for the 'numeric tower', able to abstract away the differences between python primitives and for example numpy primitives. I could not find any equivalent for Booleans. However numpy defines np.bool too, so being able to have an abstract Boolean class