[Python-ideas] Re: Custom literals, a la C++

2022-04-08 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 02:47:48PM -, Brian McCall wrote: > Asked and answered! > > > * There are an unlimited number of derived (non-SI) and compound units > > that people will want to use. > > Unlimited? You sure that problem can't be bounded? Every problem can be bounded by the amount

[Python-ideas] Re: Custom literals, a la C++

2022-04-08 Thread Chris Angelico
On Sat, 9 Apr 2022 at 02:31, Christopher Barker wrote: > > On Fri, Apr 8, 2022 at 8:29 AM Chris Angelico wrote: >> >> > > another that's using nautical miles, but *not both in the same >> > > module*? > > > Absolutely! > > There is talk about "the Application" as though that's one thing, but Pyth

[Python-ideas] Re: Custom literals, a la C++

2022-04-08 Thread Christopher Barker
On Fri, Apr 8, 2022 at 8:29 AM Chris Angelico wrote: > > > another that's using nautical miles, but *not both in the same > > > module*? Absolutely! There is talk about "the Application" as though that's one thing, but Python applications these days can be quite large collections of third part

[Python-ideas] Re: Custom literals, a la C++

2022-04-08 Thread Chris Angelico
On Sat, 9 Apr 2022 at 00:34, Steven D'Aprano wrote: > > On Tue, Apr 05, 2022 at 02:17:00PM +1000, Chris Angelico wrote: > > > Do you ever have one module that's using statute miles and > > another that's using nautical miles, but *not both in the same > > module*? The only reason to have them name

[Python-ideas] Re: Custom literals, a la C++

2022-04-08 Thread Steven D'Aprano
On Tue, Apr 05, 2022 at 02:17:00PM +1000, Chris Angelico wrote: > Do you ever have one module that's using statute miles and > another that's using nautical miles, but *not both in the same > module*? The only reason to have them namespaced to modules is to > allow different modules to use them in

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Chris Angelico
On Fri, 8 Apr 2022 at 22:56, Joao S. O. Bueno wrote: > > Hi. I've replied to the first e-mail on this thread, more than 10 days ago. > I am back, though I've read most of what was written. > > I don't think things have improved, but you sure are consuming everyone's time > > You are still repeatin

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Joao S. O. Bueno
Hi. I've replied to the first e-mail on this thread, more than 10 days ago. I am back, though I've read most of what was written. I don't think things have improved, but you sure are consuming everyone's time You are still repeating this: "more in line with the expectation of the majority, " Tho

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-08 Thread Paul Moore
On Fri, 8 Apr 2022 at 13:09, Matt del Valle wrote: > > My personal preference for adding units to python would be to make instances > of all numeric classes subscriptable, with the implementation being roughly > equivalent to: > > def __getitem__(self, unit_cls: type[T]) -> T: > return unit_

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-08 Thread Matt del Valle
My personal preference for adding units to python would be to make instances of all numeric classes subscriptable, with the implementation being roughly equivalent to: def __getitem__(self, unit_cls: type[T]) -> T: return unit_cls(self) We could then discuss the possibility of adding some im

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-08 Thread Greg Ewing
On 8/04/22 7:03 pm, Christopher Barker wrote: Are you SURE your accounting software is doing the right thing?  ;-) Well, I've only ever seen precision problems manifest themselves once, and that was when I wrote a script that used repeated multiplications by 10 as part of a process to convert a

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-08 Thread Paul Moore
On Fri, 8 Apr 2022 at 12:22, Ricky Teachey wrote: > I just get really excited at the idea of it being native to the language and > am dreaming of being able to use it more often for my every day calculations. > Right now I just don't feel confident I can. If you can describe what the Python of

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-08 Thread Ricky Teachey
On Fri, Apr 8, 2022, 2:40 AM Stephen J. Turnbull wrote: > Brian McCall writes: > Steven d'Aprano writes: > > > > you have shown nothing to justify why unit support must be built > > > into the language itself. > > > > I did what I could, but I'm not going to try and justify any more. > >

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Steven D'Aprano
On Thu, Apr 07, 2022 at 11:52:31AM -, malmiteria wrote: > I believe my gobelin exemple is a fair case of MI since we can > definitely say halfbreed *is a* corruptedgobelin *and a* proudgobelin. That is the most common relationship modelled by inheritance. > In such a case with multiple *i

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Greg Ewing
On 7/04/22 11:11 pm, malmiteria wrote: But if there was a way to tell super what class it should be a proxy of, that would be very easy to explain : when there's two parent, just give the parent you want to target as an argument to super. That sounds like exactly what Class.method(self) does

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Greg Ewing
On 7/04/22 11:52 pm, malmiteria wrote: I believe my gobelin exemple is a fair case of MI since we can definitely say halfbreed *is a* corruptedgobelin *and a* proudgobelin. I'm not so sure about that. I would agree that it's a gobelin, just as you are (presumably) a human. But a child is *not

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Antoine Rozo
If these examples were possible (I wouldn't say they are smart designs) they would lead to recursion errors. Limitations on MRO are good, they force to keep a quite simple structure. Le jeu. 7 avr. 2022 à 17:41, malmiteria a écrit : > Antoine Rozo writes: > > If the only feature you need from su

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-08 Thread Christopher Barker
On Thu, Apr 7, 2022 at 2:51 PM Greg Ewing wrote: > I don't think it's entirely about the display. It's also about > things like sum([1/10] * 10) == 1 being False. sure, but: In [18]: sum([Decimal(1) / Decimal(3)] * 3) == Decimal(1) Out[18]: False Which is just as bad -- not as "confusing" to