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

2022-04-04 Thread Alexandre Brault
On 2022-04-05 12:17 a.m., Chris Angelico wrote: On Tue, 5 Apr 2022 at 13:00, Steven D'Aprano wrote: Sure, we can demand that every application that needs to deal with US survey miles and imperial miles and international miles give them all distinct names. That's one solution, but not the

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 13:00, Steven D'Aprano wrote: > > On Tue, Apr 05, 2022 at 04:02:24AM +1000, Chris Angelico wrote: > > > Is it really that much of a problem? Tell me: How often do you REALLY > > expect to have collisions within an application, but in different > > modules? YAGNI. > > You

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 11:44, Steven D'Aprano wrote: > > On Tue, Apr 05, 2022 at 04:36:24AM +1000, Chris Angelico wrote: > > > Some unit cancellations really do result in pure scalars. The ratio of > > a circle's circumference to its diameter isn't a unit of m/m any more > > than the ratio of a

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

2022-04-04 Thread Steven D'Aprano
On Tue, Apr 05, 2022 at 04:02:24AM +1000, Chris Angelico wrote: > Is it really that much of a problem? Tell me: How often do you REALLY > expect to have collisions within an application, but in different > modules? YAGNI. You have no idea how many different definitions there are for "mile", do

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

2022-04-04 Thread Greg Ewing
On 4/04/22 3:45 pm, David Mertz, Ph.D. wrote: An electron volt is a unit of energy. Or of mass. Or of momentum. Well, in relativity they're all really the same thing, or at least interconvertible. But there are more glaring examples of this. What do you get when you multiply a number of

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

2022-04-04 Thread David Mertz, Ph.D.
On Mon, Apr 4, 2022 at 7:45 PM Ethan Furman wrote: > On 4/4/22 13:31, David Mertz, Ph.D. wrote: > > > You should probably change the thread subject to "All-and-only 7 SI > units" if that's what you mean. > > While I'm sure SI would be very useful, I suspect that any system will > have to be

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 11:05:54AM -0700, Ethan Furman wrote: > On 4/4/22 08:54, Ken Kundert wrote: > It seems to me that these "unitless' units actually have units, even if > they *appear* to cancel each other out. The term is *dimensionless* units. 1 dozen and 1 mole of objects both are

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 04:44:58PM -0700, Ethan Furman wrote: > Beyond that, do we make Python smart enough to, for example, convert > `km*km` to `km^2`, or do we let libraries provide their own functions? I'm > inclined to let libraries provide their own, as they could also implement > unit

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

2022-04-04 Thread Greg Ewing
On 4/04/22 2:42 pm, Ricky Teachey wrote: height = 5ft + 4.5in Surely we ought to be able to add these values. But what should the resulting tag be? One answer might be that the tag only tracks what kind of quantity it is -- length, mass, time, etc. Internally the number would be represented

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

2022-04-04 Thread Steven D'Aprano
On Tue, Apr 05, 2022 at 04:36:24AM +1000, Chris Angelico wrote: > Some unit cancellations really do result in pure scalars. The ratio of > a circle's circumference to its diameter isn't a unit of m/m any more > than the ratio of a circle's area to that of a circumscribed square is > a unit of

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

2022-04-04 Thread Greg Ewing
On 4/04/22 10:47 am, dn wrote: You wouldn't believe it - have interrupted typing here to receive a package. However, the clothing delivered is NOT the size ordered... Let me guess, you ordered it in cm but they delivered it in inches?-) -- Greg ___

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

2022-04-04 Thread Ethan Furman
On 4/4/22 13:31, David Mertz, Ph.D. wrote: > You should probably change the thread subject to "All-and-only 7 SI units" if that's what you mean. While I'm sure SI would be very useful, I suspect that any system will have to be useful for a much broader audience to be accepted; given the vast

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

2022-04-04 Thread malmiteria
Paul Moore writes: > this is the first time you've explicitly stated this this was more explicitely stated earlier in the thread yeah, I honestly can't blame you for not reading it all. I'll eventually try to give a quick state of today's proposal to keep it up to date. I won't have time for

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

2022-04-04 Thread malmiteria
Chris Angelico writes: > If you meant it only for me, you could have sent it privately. Well.. yeah, i probably sould have. I apologise for that. > But since you are clearly not returning the favour, I am now done. > Good luck with your proposal, maybe you can team up with jmf and make > a new

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

2022-04-04 Thread malmiteria
Paul Moore writes: > > super(A, self) does not proxy to A, but to the first *after* A in MRO order. > Correct, that's how it's defined to work. Glad we're on the same page so far. I love you profile pic by the way > That's the point - the type > argument to super() can be omitted in 99% of cases

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

2022-04-04 Thread Paul Moore
On Mon, 4 Apr 2022 at 22:19, malmiteria wrote: > What i am saying is that *if* super(A, self) *were* to call A's method, that > would be a simpler API. I understand that you're specifically responding to Chris, but to be honest, this is the first time you've explicitly stated this (unless it

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 07:21, malmiteria wrote: > > Just for everyone reading this, I'm writing this one only for Chris Angelico. > As much as some others here have been heating up during the discussion, which > is understandable, i believe most of you were willing / able to provide a > fair

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

2022-04-04 Thread malmiteria
Just for everyone reading this, I'm writing this one only for Chris Angelico. As much as some others here have been heating up during the discussion, which is understandable, i believe most of you were willing / able to provide a fair discussion, and still are, which shows maturity, and is

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

2022-04-04 Thread David Mertz, Ph.D.
You should probably change the thread subject to "All-and-only 7 SI units" if that's what you mean. On Mon, Apr 4, 2022 at 1:46 PM Brian McCall wrote: > > I drove 20 minutes up the road to by a bushel (US, not British) of U.S. > No. 1. apples, to make apple cider. On my return trip, I stopped

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

2022-04-04 Thread David Mertz, Ph.D.
> > Units have infinite precision, so grades and tolerances are also > irrelevant. > Not if you believe in Planck lengths (or quantum states) :-). -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 05:47, Steven D'Aprano wrote: > > On Mon, Apr 04, 2022 at 03:39:26PM +1000, Chris Angelico wrote: > > > I would say that 2.54in/1cm should be equal to 1. > > 2.54 inches is not 1 cm. This is how you get a billion dollar spacecraft > crashing into Mars instead of landing

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 05:44, Steven D'Aprano wrote: > > Should 2.54 in / 1 cm evaluate to 2.54 in/cm or should > > it evaluate to 1? I'd much rather it evaluate to 1 > > There are only two reasonable ways to parse that, depending on > precedence of units and operators: > > * (2.54 inches) / (1

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 03:39:26PM +1000, Chris Angelico wrote: > I would say that 2.54in/1cm should be equal to 1. 2.54 inches is not 1 cm. This is how you get a billion dollar spacecraft crashing into Mars instead of landing softly :-) -- Steve

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 04:22:25AM -, Brian McCall wrote: [Chris] > > Part of the problem here is that Python has to be many many things. > > Which set of units is appropriate? For instance, in a lot of contexts, > > it's fine to simply attach K to the end of something to mean "a > >

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 06:16:49AM -, Brian McCall wrote: > So a comprehensive implementation of units would not require more than > 160 units, and in reality, a "sufficient" implementation would need > only 7. The idea that a system which only supported the seven SI base quantities, and

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 05:45:52PM -, Brian McCall wrote: > Anyway, you mentioned you knew of at least 1000 units. I count 7. You have > another 993? Will 2451 do? [steve@ando ~]$ units 2438 units, 71 prefixes, 32 nonlinear units -- Steve ___

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 04:19, Ethan Furman wrote: > > On 4/3/22 22:39, Chris Angelico wrote: > > On Mon, 4 Apr 2022 at 14:22, Brian McCall wrote: > > >> Related to these questions, there is the question of what to do about > mixed systems? > > Should 2.54 in / 1 cm evaluate to 2.54 in/cm or

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

2022-04-04 Thread Ricky Teachey
On Mon, Apr 4, 2022 at 2:24 PM Steven D'Aprano wrote: > On Sun, Apr 03, 2022 at 10:42:16PM -0400, Ricky Teachey wrote: > > > I was cheerleading this effort earlier and I still think it would be a > > massive contribution to needs of the engineering world to solve this > > problem at the language

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

2022-04-04 Thread Brian McCall
> For example, consider currencies. There are currently hundreds of national > currencies and thousands of cryptocurrencies. They all have the same basic > fundamental unit of “value”, but value is only loosely defined. Furthermore, > there is no fixed ratio between the currency and its

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

2022-04-04 Thread Paul Moore
On Mon, 4 Apr 2022 at 18:59, malmiteria wrote: > super(A, self) does not proxy to A, but to the first *after* A in MRO order. Correct, that's how it's defined to work. > When you're actually in need to passing arguments to super, you very likely > know what class you're gonna be targeting, and

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

2022-04-04 Thread Steven D'Aprano
On Sun, Apr 03, 2022 at 10:42:16PM -0400, Ricky Teachey wrote: > I was cheerleading this effort earlier and I still think it would be a > massive contribution to needs of the engineering world to solve this > problem at the language level. But boy howdy is it a tough but of a problem > to crack.

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

2022-04-04 Thread Ethan Furman
On 4/3/22 22:39, Chris Angelico wrote: > On Mon, 4 Apr 2022 at 14:22, Brian McCall wrote: >> Related to these questions, there is the question of what to do about mixed systems? > Should 2.54 in / 1 cm evaluate to 2.54 in/cm or should it evaluate to 1? > > I would say that 2.54in/1cm should be

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 03:58, malmiteria wrote: > > Steven D'Aprano writes: > > > feature 1 (of super alone): proxying the parent. > > > What most people think super does (and expect it to do): > > > it allows to call method from *the* (most people don't think of > > > multiple inheritance)

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

2022-04-04 Thread Ethan Furman
On 4/4/22 08:54, Ken Kundert wrote: > Now consider the issue of “unitless units”. In electrical circuit we often talk > about gain, which it the ratio between the signal level at the output of > a circuit relative to the signal level at the input. But you need to be > specific about how you

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 03:58, Marco Sulla wrote: > > On Mon, 4 Apr 2022 at 07:47, Chris Angelico wrote: > > > > Not a particle physicist, so I don't know what the usage actually is, > > but wouldn't mass actually be eV/c²? If that's frequently written as > > simply "eV", then that's another

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

2022-04-04 Thread Chris Angelico
On Tue, 5 Apr 2022 at 00:48, 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? There are few things I can > think of that could bound

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

2022-04-04 Thread malmiteria
Steven D'Aprano writes: > > feature 1 (of super alone): proxying the parent. > > What most people think super does (and expect it to do): > > it allows to call method from *the* (most people don't think of > > multiple inheritance) parent. > For single inheritance, that is exactly what it does,

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

2022-04-04 Thread Brian McCall
> I drove 20 minutes up the road to by a bushel (US, not British) of U.S. No. > 1. apples, to make apple cider. On my return trip, I stopped at the hardware > store to buy a 2 lb box of 1-3/4" ring shank 12 penny nails. I used my 7/8 > hole kitchen planer blade to grate the apples, then

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

2022-04-04 Thread Ricky Teachey
On Mon, Apr 4, 2022 at 11:55 AM Ken Kundert wrote: > I think there is one more point worth making here. There is a suggestion > that > dimensional analysis can underpin a units system. Actually, the idea that > all > units can be broken down into a small set of fundamental units is very >

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 07:46:12AM -, Brian McCall wrote: > Now do it for NumPy arrays In response to Greg: [quoting Greg] I'm not convinced there's a need for new syntax here. 63*lbs 77*km/hr With appropriate definitions of lbs, km and hr these can be made to construct numbers

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

2022-04-04 Thread Sebastian Berg
On Mon, 2022-04-04 at 09:14 -0700, Ken Kundert wrote: > As why it is naive, see my previous post where I talk about the > limitations of dimensional analysis. > > As a point of reference, I have been developing software for > electrical engineers for over 40 years.  That software uses physical >

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

2022-04-04 Thread malmiteria
Greg Ewing writes: > 1. You hate the existing MRO and super() mechanism with a passion > and want to rip it out. I don't hate it, I believe it makes for the most misunderstood python feature for a reason, and i'm trying to adress it. > 2. People have objected that this would remove useful

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

2022-04-04 Thread malmiteria
Steven D'Aprano writes: > I think that where malmiteria gets it wrong is that he thinks that super > is broken I do not, i think its design could be improved overall, but i don't think it's broken. At best I'd argue it can't be used in all of the use case you'd expect for it. > Changing super

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

2022-04-04 Thread David Mertz, Ph.D.
Just to elaborate on units I use, here's a hypothetical (not stuff that actually happened today, but very commonplace nature): I drove 20 minutes up the road to by a bushel (US, not British) of U.S. No. > 1. apples, to make apple cider. On my return trip, I stopped at the > hardware store to buy

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

2022-04-04 Thread Ken Kundert
As why it is naive, see my previous post where I talk about the limitations of dimensional analysis. As a point of reference, I have been developing software for electrical engineers for over 40 years. That software uses physical quantities (voltage current, resistance, capacitance, etc.)

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

2022-04-04 Thread Ken Kundert
As why it is naive, see my previous post where I talk about the limitations of dimensional analysis. As a point of reference, I have been developing software for electrical engineers for over 40 years. That software uses physical quantities (voltage current, resistance, capacitance, etc.)

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

2022-04-04 Thread Ken Kundert
I think there is one more point worth making here. There is a suggestion that dimensional analysis can underpin a units system. Actually, the idea that all units can be broken down into a small set of fundamental units is very limiting and results in many vexing issues. For example, consider

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

2022-04-04 Thread Brian McCall
> Much of this discussion is based on a misconception. Units and SI scale > factors > are very useful in software that describes or interacts with the real world, > but > primarily on input and output. They are not normally used for internal > calculations. The idea that one carries units

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

2022-04-04 Thread Brian McCall
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? There are few things I can think of that could bound this problem in a performance-friendly manner. In terms of the

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

2022-04-04 Thread Brian McCall
Asked and answered! Although, see below*, the additional representations of these numbers does not mean that "int", "bool", and "float" have no place in the core language. *Here is a URL to a GIF of the good people of Letterkenny saying "to be fair":

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

2022-04-04 Thread Brian McCall
Back in my original post, I pointed out that engineers and scientists in their modern day workflows are expected to have basic programming language skills, and are expected to use those skills when pre-packaged software solutions leave gaps in their workflows, but they are explicitly told that

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

2022-04-04 Thread David Mertz, Ph.D.
On Mon, Apr 4, 2022 at 3:53 AM Chris Angelico wrote: > The 160 units would be more likely to have collisions though. Also, > the base and derived SI units will be used with magnitude prefixes, > The supposed 160 are far fewer than I use on a daily (or at least weekly) basis. Yes, all the rest

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 08:28:31AM +1000, Chris Angelico wrote: > What do you intend for dependency injection to do with this scream > method? What would make sense? You've already designed something that > works differently. I don't know why malmiteria keeps talking about dependency injection.

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

2022-04-04 Thread David Mertz, Ph.D.
On Mon, Apr 4, 2022, 2:17 AM Brian McCall > For instance, I don't think there would be much uproar if "teaspoons" were left out of any kind of implementation. Apparently someone other than you does the cooking in you household! ___ Python-ideas mailing

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

2022-04-04 Thread Steven D'Aprano
On Sun, Apr 03, 2022 at 03:09:18PM -, malmiteria wrote: > feature 1 (of super alone): proxying the parent. > What most people think super does (and expect it to do): > it allows to call method from *the* (most people don't think of > multiple inheritance) parent. For single inheritance,

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

2022-04-04 Thread Steven D'Aprano
On Sun, Apr 03, 2022 at 07:24:42PM -, Brian McCall wrote: > Let's say we have one of your class-ical ( :D ) geometrical shapes > hierarchy, including an abstract Shape class. > > ``` > class Shape(abc.ABC): > @abc.abstractmethod > def area(self): > "" The rest of your code

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

2022-04-04 Thread Simão Afonso
On 2022-04-04 01:19:13, pyt...@shalmirane.com wrote: > This implies that it is only necessary to provide a package for > reading and writing physical quantities, and indeed such a package > exists: QuantiPhy. QuantiPhy came out of the ideas that were raised > the last time this topic was

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

2022-04-04 Thread Chris Angelico
On Mon, 4 Apr 2022 at 20:50, Steven D'Aprano wrote: > > On Mon, Apr 04, 2022 at 07:17:55PM +1200, Greg Ewing wrote: > > On 4/04/22 9:35 am, malmiteria wrote: > > >And just to make it clear, I am not under the impression super can only > > >target one class. > > >What i'm saying here is that it is

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 07:17:55PM +1200, Greg Ewing wrote: > On 4/04/22 9:35 am, malmiteria wrote: > >And just to make it clear, I am not under the impression super can only > >target one class. > >What i'm saying here is that it is the most common impression the average > >developper would

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

2022-04-04 Thread Steven D'Aprano
On Mon, Apr 04, 2022 at 08:27:45AM -, Brian McCall wrote: > Why don't we allow different libraries to use different, incompatible > implementations of integers, floating points, and bool? We do. numpy supports 32-bit and 64-bit ints and possibly others, gmpy supports mpz integers. I don't

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

2022-04-04 Thread Chris Angelico
On Mon, 4 Apr 2022 at 18:28, Brian McCall wrote: > > Why don't we allow different libraries to use different, incompatible > implementations of integers, floating points, and bool? Standard units are > just as immutable as any of these data types. > Those three data types are unambiguous, but

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

2022-04-04 Thread Brian McCall
Why don't we allow different libraries to use different, incompatible implementations of integers, floating points, and bool? Standard units are just as immutable as any of these data types. ___ Python-ideas mailing list -- python-ideas@python.org To

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

2022-04-04 Thread python
Much of this discussion is based on a misconception. Units and SI scale factors are very useful in software that describes or interacts with the real world, but primarily on input and output. They are not normally used for internal calculations. The idea that one carries units on variables

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

2022-04-04 Thread Chris Angelico
On Mon, 4 Apr 2022 at 16:56, Ben Rudiak-Gould wrote: > I feel like one of the biggest sticking points in this thread is that people > are arguing for a new kind of global scope just for units, and the sole > reason seems to be that they want short names for them. > > The register_numeric_suffix

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

2022-04-04 Thread Chris Angelico
On Mon, 4 Apr 2022 at 16:41, Brian McCall wrote: > > How something is used is not the same as how it is defined. I might use my > car key to open my mail, but if I ask someone if they've seen my letter > opener, they're probably not going to be able to help me find my car keys. > +1 QOTW! >

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

2022-04-04 Thread Brian McCall
Now do it for NumPy arrays ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

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

2022-04-04 Thread Brian McCall
The C++ way is custom literals (it's where this thread originated) https://mail.python.org/archives/list/python-ideas@python.org/thread/MFZ52D32YTPYIQVUEZJWW3DUYQUBR5R7/ One problem I am seeing is a misunderstanding between standard, well-defined units, and technical lingo - for which I am not

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

2022-04-04 Thread Greg Ewing
On 4/04/22 10:20 am, Chris Angelico wrote: import sys sys.register_numeric_suffix("m", lambda n: unit(n, "meter")) sys.register_numeric_suffix("mol", lambda n: unit(n, "mole")) A global registry seems like a really bad idea. What if two libraries want to use different, incompatible

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

2022-04-04 Thread Greg Ewing
On 4/04/22 9:45 am, Ethan Furman wrote: Well, if we're spit-balling ideas, what about:     63_lbs    77_km/hr I'm not convinced there's a need for new syntax here. 63*lbs 77*km/hr With appropriate definitions of lbs, km and hr these can be made to construct numbers with attached

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

2022-04-04 Thread Greg Ewing
On 4/04/22 9:35 am, malmiteria wrote: And just to make it clear, I am not under the impression super can only target one class. What i'm saying here is that it is the most common impression the average developper would have. How do you know this? Have you undertaken a survey of randomly

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

2022-04-04 Thread Greg Ewing
On 4/04/22 9:12 am, malmiteria wrote: So, allow me to make it clear, I do get its value. Its value appears in the other use cases i account for, and wanna provide dedicated features for. (before getting rid of super and MRO's ability to provide those use case). So, if I understand correctly:

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

2022-04-04 Thread Brian McCall
> The trouble is that SI isn't the only set of units out there. And > particularly if you support SI derived units, there will be > innumerable collisions of abbreviations with other systems. Unless > you're going to mandate *in the language* that SI units are the only > ones permitted (and thus

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

2022-04-04 Thread Ben Rudiak-Gould
On Sun, Apr 3, 2022 at 10:10 PM Chris Angelico wrote: > On Mon, 4 Apr 2022 at 14:13, Ricky Teachey wrote: > > What does that idea bring other than being able to say 5.0m > [...] instead of 5.0*m [...]? > > A large amount of clarity, readability, and namespacing (you don't have to > pollute your

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

2022-04-04 Thread Brian McCall
> This is just flatly wrong of usage in particle physics. Electron volts are > precisely the default units used to describe the mass of subatomic > particles. I don't know what to tell you man. Here's Wikipedia. If you follow the link to the actual SI publication, it says the same thing. How

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

2022-04-04 Thread Brian McCall
I think I posted this somewhere else in this thread, or the previous thread. argparse can handle negative numbers, but only of one of the built-in primitive types. See example below: ``` import re, argparse class meters(float): def __new__(cls, x): return super().__new__(cls,

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

2022-04-04 Thread Brian McCall
> There are thousands of units in use in sciences, commerce, engineering In the SI system, there are: 7 base SI standard units 22 named, derived standard units 14 alternative standard units of measure that are commensurate with one of the 29 base and derived units, and ~35 units (not symbols)