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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 15:41, Greg Ewing wrote: > > if proudgobelin and corruptegobelin are published by a game_engine library, > > the game_engine user would most likely not be aware (nor should he care) > > that they both inherit from a same parent. > > If someone is going to munge those

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

2022-04-06 Thread Greg Ewing
On 7/04/22 5:22 am, malmiteria wrote: Also, i believe the idea of using anything but super to access a parent methods is far from obvious to most people. That might be true for people who learned Python recently enough. When I started using Python, super didn't even exist, so I got used to

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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 10:19, Brian McCall wrote: > > > Agreed, this is just using Python as a glorified calculator. I understand > > that this is just an example, but I *am* curious, is the bulk of what you > > do simply calculations like this, or do your more complicated examples tend > > to

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

2022-04-06 Thread Greg Ewing
On 6/04/22 8:58 pm, Mark Dickinson via Python-ideas wrote: I'd be curious to know what alternatives you see. When a user writes `x + y` with both `x` and `y` instances of `decimal.Decimal`, the decimal module needs to know what precision to compute the result to (as well as what rounding mode

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

2022-04-06 Thread Brian McCall
> Agreed, this is just using Python as a glorified calculator. I understand > that this is just an example, but I *am* curious, is the bulk of what you do > simply calculations like this, or do your more complicated examples tend to > be more like actual programs? I have never shipped code

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

2022-04-06 Thread Brian McCall
Mike and Andre, thanks for the links! I was indeed planning to take a crack at implementing some ideas. First, for my part, I need to get approval from the people who own my intellectual property ;-) I also figured it would take me a while to sift through the Python code, which I have never

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

2022-04-06 Thread André Roberge
On Wed, Apr 6, 2022 at 7:05 PM Mike Miller wrote: > > On 2022-04-06 12:36, Paul Moore wrote: > > > And if new syntax is a clear win even with such a library, > > then designing a language feature that enables better syntax for that > > library would still be possible (and there would be a clear

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

2022-04-06 Thread Mike Miller
On 2022-04-06 12:36, Paul Moore wrote: And if new syntax is a clear win even with such a library, then designing a language feature that enables better syntax for that library would still be possible (and there would be a clear use case for it, making the arguments easier to make). If

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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 07:41, Brendan Barnwell wrote: > > On 2022-04-06 14:28, Chris Angelico wrote: > > What do the specialized libraries offer that Decimal doesn't? Is it > > really worth all that hassle for the sake of teaching something that, > > in production, would just be done with floats

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

2022-04-06 Thread Brendan Barnwell
On 2022-04-06 14:28, Chris Angelico wrote: What do the specialized libraries offer that Decimal doesn't? Is it really worth all that hassle for the sake of teaching something that, in production, would just be done with floats and the math module anyway? If the decimal module did not already

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

2022-04-06 Thread Oscar Benjamin
On Wed, 6 Apr 2022 at 21:47, Chris Angelico wrote: > > On Thu, 7 Apr 2022 at 05:37, Oscar Benjamin > wrote: > > > > > > Not so obvious to me, as it would require inordinate amounts of > > > fiddling around when you want to dynamically adjust your precision. > > > You'd have to reassign every

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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 07:22, Oscar Benjamin wrote: > > On Wed, 6 Apr 2022 at 21:47, Chris Angelico wrote: > > > > On Thu, 7 Apr 2022 at 05:37, Oscar Benjamin > > wrote: > > > > > > > > Not so obvious to me, as it would require inordinate amounts of > > > > fiddling around when you want to

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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 05:37, Oscar Benjamin wrote: > > On Wed, 6 Apr 2022 at 17:48, Chris Angelico wrote: > > > > On Thu, 7 Apr 2022 at 02:17, Christopher Barker wrote: > > > > > > On Wed, Apr 6, 2022 at 5:11 AM Oscar Benjamin > > > wrote: > > >> > I'd be curious to know what alternatives you

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

2022-04-06 Thread Oscar Benjamin
On Wed, 6 Apr 2022 at 17:48, Chris Angelico wrote: > > On Thu, 7 Apr 2022 at 02:17, Christopher Barker wrote: > > > > On Wed, Apr 6, 2022 at 5:11 AM Oscar Benjamin > > wrote: > >> > I'd be curious to know what alternatives you see. When a user writes `x > >> > + y` with both `x` and `y`

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

2022-04-06 Thread Paul Moore
On Wed, 6 Apr 2022 at 16:51, Brian McCall wrote: > Before I get to this example, though, there is more to arguments for the > "need" than just counter-examples. I keep using quotes because nothing is > really a need for anything. Yes, it's not about "need" in an absolute sense, but more about

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-04-06 Thread Brian McCall
> Unfortunately, Python simply doesn't have enough symbols available. > Using precisely one opener/closer for each type is highly limiting, > since the only characters available are those on a US-English keyboard > and in the ASCII set. It would be nice if, for instance, ∅ could mean > "new empty

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

2022-04-06 Thread malmiteria
Steven D'Aprano writes: > > All we have today is the screwhammer, and in cases the screw part > > don't work, you're telling me to get rid of it all. hammer part > > included. > That's not how I see it. > I see that we have a screwdriver (inheritence, including multiple > inheritence) which

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

2022-04-06 Thread Brian McCall
Oops, my examples have some other problems: > # λ = 550e-9nm should be > # λ = 550nm and > # λ = 550e-9 [nm] should be > # λ = 550 [nm] ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

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

2022-04-06 Thread Brian McCall
> Thank you for all the examples, that should help a lot. Out of curiosity, > those are the corrected versions of the code? Where was the mistake in the > original? Happy to help! The original was unitless altogether, so that was the first problem. The particular error was λ. I typically work

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

2022-04-06 Thread Chris Angelico
On Thu, 7 Apr 2022 at 02:17, Christopher Barker wrote: > > On Wed, Apr 6, 2022 at 5:11 AM Oscar Benjamin > wrote: >> > I'd be curious to know what alternatives you see. When a user writes `x + >> > y` with both `x` and `y` instances of `decimal.Decimal`, the decimal >> > module needs to know

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

2022-04-06 Thread Ethan Furman
On 4/6/22 08:50, Brian McCall wrote: > Alright, now let's look at an example. Again, it's not my best, let's go with it. This is just > a calculation of the expected number of photons to reach a pixel through a camera of a given > f-number (F). I mentioned this has bitten me before. All that

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

2022-04-06 Thread Christopher Barker
On Wed, Apr 6, 2022 at 5:11 AM Oscar Benjamin wrote: > > >Personally I think giving Decimal a global context was a mistake, [...] > I agree here -- though honestly, I think the benefits of Decimal are often misrepresented. Interestingly, the variable precision is the real bonus, not the decimal

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

2022-04-06 Thread Brian McCall
Wow, this thread has grown quite a bit in the last two days. And there's some really good points raised alongside the light trolling here and there. While the discussion around implementation is important and very interesting, I think the question around motivation is critical. Since I see some

[Python-ideas] Re: Allow os.getenv to optionally convert result to boolean

2022-04-06 Thread Eric V. Smith
On 4/6/2022 2:23 PM, Jeff Edwards wrote: I will say I think that last comment misses the point.  It’s true that environment variable boolean configuration is definitely common enough I wouldn’t balk at some normalized methods for handling it.  But, I think the point has been well made it’s an

[Python-ideas] Re: Allow os.getenv to optionally convert result to boolean

2022-04-06 Thread Jeff Edwards
Agreed! On Wed, Apr 6, 2022 at 7:31 AM Eric V. Smith wrote: > On 4/6/2022 2:23 PM, Jeff Edwards wrote: > > I will say I think that last comment misses the point. It’s true that > environment variable boolean configuration is definitely common enough I > wouldn’t balk at some normalized methods

[Python-ideas] Re: Allow os.getenv to optionally convert result to boolean

2022-04-06 Thread Jeff Edwards
I will say I think that last comment misses the point. It’s true that environment variable boolean configuration is definitely common enough I wouldn’t balk at some normalized methods for handling it. But, I think the point has been well made it’s an opinionated choice that Python can’t force on

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

2022-04-06 Thread Oscar Benjamin
On Wed, 6 Apr 2022 at 09:59, Mark Dickinson via Python-ideas wrote: > > Broken off from the "Custom literals, a la C++" thread: > > Greg Ewing wrote: > >Personally I think giving Decimal a global context was a mistake, [...] > > so arguing that "it's no worse than Decimal" isn't going to do much

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

2022-04-06 Thread Steven D'Aprano
On Wed, Apr 06, 2022 at 08:34:35PM +1200, Greg Ewing wrote: > On 6/04/22 10:41 am, Chris Angelico wrote: > >I don't think anyone would ever say that a > >parsec (several light years) should be considered equivalent to a > >second of latitude (a handful of meters) just because they both have > >an

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

2022-04-06 Thread Steven D'Aprano
On Wed, Apr 06, 2022 at 08:28:59PM +1200, Greg Ewing wrote: > I actually think super() is misnamed and should really be called > next_class() or something like that. There might be less confusion > about its intended use then. Heh, we should rename it frábær(), that will ensure that nobody will

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

2022-04-06 Thread Steven D'Aprano
On Tue, Apr 05, 2022 at 09:55:00PM +1200, Greg Ewing wrote: > I would also say that if you're passing super anything *other* > than the class where the method is defined, you're trying to > be too clever by half, and will get bitten. +1 In Python 3, you should (nearly?) always just call the

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

2022-04-06 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 09:45:32PM -, malmiteria wrote: > All we have today is the screwhammer, and in cases the screw part > don't work, you're telling me to get rid of it all. hammer part > included. That's not how I see it. I see that we have a screwdriver (inheritence, including

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

2022-04-06 Thread Steven D'Aprano
On Tue, Apr 05, 2022 at 04:27:45PM +0100, Paul Moore wrote: > On Tue, 5 Apr 2022 at 12:37, malmiteria wrote: > > 5) replacing MRO with a method resolution that I describe at the top > > of my post: - accessing an attribute / method that multiple parent > > can provide would raise an

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

2022-04-06 Thread Steven D'Aprano
On Wed, Apr 06, 2022 at 02:47:57AM +1200, Greg Ewing wrote: > I think you misunderstand the reason why super() accepts a class > argument. > > It's purely for historical reasons. No, it is because it actually does need to know which class it is being called from, as well as the object that

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

2022-04-06 Thread Mark Dickinson via Python-ideas
Broken off from the "Custom literals, a la C++" thread: Greg Ewing wrote: >Personally I think giving Decimal a global context was a mistake, [...] > so arguing that "it's no worse than Decimal" isn't going to do much > to convince me. :-) I'd be curious to know what alternatives you see. When a

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

2022-04-06 Thread Greg Ewing
On 6/04/22 10:41 am, Chris Angelico wrote: I don't think anyone would ever say that a parsec (several light years) should be considered equivalent to a second of latitude (a handful of meters) just because they both have an angular size of one second! Although if you're Han Solo then it's a

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

2022-04-06 Thread Greg Ewing
On 6/04/22 5:52 am, malmiteria wrote: Some exemple i give including, but not limited to the gobelin exemple are a fair use case in which you'd want to use the argumented version of super. No, the gobelin example is an example of when NOT to use super(). Multiple people have told you that,

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

2022-04-06 Thread Greg Ewing
On 5/04/22 4:17 pm, Chris Angelico wrote: If your application needs to use both statute and nautical miles in the same module (most likely the main module), then it's going to have an issue, If there's a single global registry, and they both register the unit under the same name, then there