[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Ricky Teachey
On Tue, Jun 23, 2020 at 2:59 PM Wes Turner wrote: > > ∆y(P, H,L, E, I) := H * L^4 * P / (384 * E * I) > > ```python > Δy = lambda P, H, L, E, I: H * L**4 * P / (384 * E * I) > Δy > ``` > (P, H, L, E, I)> > > Is there a good way to redefine the '^' operator for {int, float, Decimal, > Fracti

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Wes Turner
> ∆y(P, H,L, E, I) := H * L^4 * P / (384 * E * I) ```python Δy = lambda P, H, L, E, I: H * L**4 * P / (384 * E * I) Δy ``` (P, H, L, E, I)> Is there a good way to redefine the '^' operator for {int, float, Decimal, Fraction, numbers.Number}? Why would it be dangerous to monkey-patch global

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Ricky Teachey
On Tue, Jun 23, 2020 at 11:09 AM Rhodri James wrote: > On 23/06/2020 15:12, Ricky Teachey wrote: > > On Tue, Jun 23, 2020 at 9:08 AM Mathew Elman > wrote: > > > >> Well there you go, good point. > >> I didn't really like it being an operator myself. But I can see having a > >> math.tolerance cla

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Rhodri James
On 23/06/2020 15:12, Ricky Teachey wrote: On Tue, Jun 23, 2020 at 9:08 AM Mathew Elman wrote: Well there you go, good point. I didn't really like it being an operator myself. But I can see having a math.tolerance class being useful. On Tue, 23 Jun 2020 at 13:53, Jonathan Goble wrote: On Tu

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Ricky Teachey
On Tue, Jun 23, 2020 at 9:08 AM Mathew Elman wrote: > Well there you go, good point. > I didn't really like it being an operator myself. But I can see having a > math.tolerance class being useful. > > On Tue, 23 Jun 2020 at 13:53, Jonathan Goble wrote: > >> On Tue, Jun 23, 2020 at 8:44 AM Mathew

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Mathew Elman
Well there you go, good point. I didn't really like it being an operator myself. But I can see having a math.tolerance class being useful. On Tue, 23 Jun 2020 at 13:53, Jonathan Goble wrote: > On Tue, Jun 23, 2020 at 8:44 AM Mathew Elman > wrote: > >> Perhaps a more versatile operator would be

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Jonathan Goble
On Tue, Jun 23, 2020 at 8:44 AM Mathew Elman wrote: > Perhaps a more versatile operator would be to introduce a +- operator that > would return an object with an __eq__ method that checks for equality in > the tolerance i.e > > a == b +- 0.5 > This is already valid syntax, because unary minu

[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-23 Thread Mathew Elman
Perhaps a more versatile operator would be to introduce a +- operator that would return an object with an __eq__ method that checks for equality in the tolerance i.e a == b +- 0.5 Although I don't like this either since you could achieve the same thing with something like this: class Tol

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-23 Thread Greg Ewing
On 23/06/20 3:23 am, Jonathan Crall wrote: Indicator variables which take a value of either zero are one are extremely common. Yes, but they're explicitly defined as numbers, not truth values. -- Greg ___ Python-ideas mailing list -- python-ideas@pyt