[Python-ideas] Re: @classproperty, @abc.abstractclasspropery, etc.

2020-12-15 Thread Paolo Lammens
Old thread, pity it didn't get any traction. I second this. Except perhaps the @staticproperty: since a static (method|property) is bound to neither the instance nor the class, it doesn't seem straightforward/intuitive as to where the value set in the setter should go. E.g. if it sets an attri

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Marco Sulla
On Tue, 15 Dec 2020 at 17:41, Chris Angelico wrote: > I learned BOMDAS - Brackets, O (varies in expansion but always minor > things you don't often see), Multiplication, Division, Addition, > Subtraction. For some reason it's also written BODMAS, which has the > exact same meaning (since multiplic

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 04:15:52PM +, David Mertz wrote: > It feels like a chimp trying to pantomime a philosopher, really. As > someone with a doctorate in philosophy, I feel triggered :-). Quoting "A Fish Called Wanda": Otto: Apes don't read philosophy. Wanda: Yes they do, Otto, t

[Python-ideas] Re: Function for fetching what months between two dates

2020-12-15 Thread Marco Sulla
On Tue, 15 Dec 2020 at 15:32, Steven D'Aprano wrote: > > On Tue, Dec 15, 2020 at 03:08:51AM -, qaidjoharbarbh...@gmail.com wrote: > > Hello, > > > > Greetings! > > > > I have the following idea of adding a function in Lib/datetime.py > > which when called with the datetime.date object returns

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Christopher Barker
I'm going to answer the original question, even though I don't quite understand it: > Using explicit parenthesization to convey aspects of semantic meaning? Absolutely not -- for no other reason that it would break potentially a LOT of code. If there IS some new useful semantics that could be con

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Chris Angelico
On Wed, Dec 16, 2020 at 3:16 AM David Mertz wrote: > > On Tue, Dec 15, 2020 at 11:22 AM Chris Angelico wrote: >> I'm pretty sure most of us learned *in grade school* about BOMDAS or >> BODMAS or PEMDAS or whatever mnemonic you pick. > > I don't think I ever learned such acronyms! I mean, yes I le

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread David Mertz
On Tue, Dec 15, 2020 at 11:22 AM Chris Angelico wrote: > Seriously, are you actually unaware of this fundamental, or are you > playing dumb to try to make a point? I'm still trying to figure out > your point here. I've already put him in my killfile, but probably unwisely, I still see the follo

[Python-ideas] Re: Conditional with statements

2020-12-15 Thread Jonathan Crall
Thanks for the link, the rationale for rejection seems reasonable. On Fri, Dec 11, 2020 at 8:19 PM Chris Angelico wrote: > On Sat, Dec 12, 2020 at 11:42 AM Jonathan Crall > wrote: > > > > I'm not sure if this has been asked / suggested before. > > > > I'm wondering if there is any interest in c

[Python-ideas] Re: Function for fetching what months between two dates

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 03:08:51AM -, qaidjoharbarbh...@gmail.com wrote: > Hello, > > Greetings! > > I have the following idea of adding a function in Lib/datetime.py > which when called with the datetime.date object returns the months > between the object datetime.date and the object datet

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 02:24:48PM +0300, Paul Sokolovsky wrote: > As I showed right in my first mail, in "a.b()", > "a.b" doesn't get evaluated at all (since CPython3.7). `a.b` still has to be looked up, even with the new fast LOAD_METHOD byte-code. The difference is that it may be able to avoi

[Python-ideas] Re: Function for fetching what months between two dates

2020-12-15 Thread Valentin Berlier
Hi. Bundling this into the standard library doesn't seem to provide any real advantage over defining it as a free-standing utility function in your own code. And if it's in your own code you can easily tweak it if you need to :) ___ Python-ideas maili

[Python-ideas] Function for fetching what months between two dates

2020-12-15 Thread qaidjoharbarbhaya
Hello, Greetings! I have the following idea of adding a function in Lib/datetime.py which when called with the datetime.date object returns the months between the object datetime.date and the object datetime.date passed as the date_to argument in function. Herewith is the attached link to the

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 01:16:21PM +0300, Paul Sokolovsky wrote: > You're now just a step away from the "right answer". Will you make it? > I did. Sorry Paul, but you didn't. You fooled yourself by comparing chalk and cheese, and imagining that because you can eat cheese (change the order of op

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 12:49:26PM +0300, Paul Sokolovsky wrote: > > Are you asking for a semantic difference (the two statements do > > something different) or an implementation difference (the two > > statements do the same thing in slightly different ways)? > > I'm asking for semantic differe

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Greg Ewing
On 16/12/20 12:24 am, Paul Sokolovsky wrote: That's good answer, thanks. But... it doesn't correspond to the implementation reality. Why are we talking about implementation? You said you wanted to keep to the conceptual level. At that level, there is NO difference at all. -- Greg

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Greg Ewing
On 15/12/20 11:28 pm, Paul Sokolovsky wrote: that table is not complete. For example, "," (comma) is a (context-dependent) operator in Python, yet that table doesn't have explicit entry for it. Unary "*" and "**" are other context-dependent operators. (Unary "@" too.) Those things aren't consid

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Greg Ewing
On 15/12/20 11:16 pm, Paul Sokolovsky wrote: I would suggest us rising up in abstraction level a bit, and think not in terms of "intermediate variables" but in terms of "intermediate storage locations". The fact that it's a *named* intermediate storage location is important, because it means th

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Tue, 15 Dec 2020 23:37:59 +1300 Greg Ewing wrote: > On 15/12/20 10:04 pm, Paul Sokolovsky wrote: > > Example 1: > > > > a + b + c vs a + (b + c) > > > > Question 1: > > Do you agree that there's a clear difference between left and right > > expression? > > Yes, because the def

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Chris Angelico
On Tue, Dec 15, 2020 at 9:22 PM Paul Sokolovsky wrote: > On Tue, 15 Dec 2020 20:17:37 +1100 > Chris Angelico wrote: > > > On Tue, Dec 15, 2020 at 8:04 PM Paul Sokolovsky > > wrote: > > > So, let's try simple yes/no questions: > > > > > > Example 1: > > > > > > a + b + c vs a + (b + c) > > >

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Greg Ewing
On 15/12/20 10:49 pm, Paul Sokolovsky wrote: the question is what semantic (not implementational!) shift happened in 3.7 (that's the point when it started to be compiled differently). There was no semantic shift. The change had *nothing* to do with semantics. It was *purely* an optimisation. I

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Greg Ewing
On 15/12/20 10:04 pm, Paul Sokolovsky wrote: Example 1: a + b + c vs a + (b + c) Question 1: Do you agree that there's a clear difference between left and right expression? Yes, because the default order of operations in Python is defined so that a + b + c is the same as (a + b) + c. Ex

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Jeff Allen
On 13/12/2020 22:09, Paul Sokolovsky wrote: Thanks for hanging with me so far, we're getting to the crux of the question: Do you think there can be difference between the following two expressions: obj.meth() (obj.meth)() ? No. The value of an expression in parentheses is the value of the e

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Tue, 15 Dec 2020 20:18:11 +1100 Chris Angelico wrote: > On Tue, Dec 15, 2020 at 8:08 PM Paul Sokolovsky > wrote: > > > > Hello, > > > > On Mon, 14 Dec 2020 02:17:52 -0500 > > David Mertz wrote: > > > > > On Sun, Dec 13, 2020, 5:11 PM Paul Sokolovsky d > > > > > > > a + b + c vs

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Tue, 15 Dec 2020 20:17:37 +1100 Chris Angelico wrote: > On Tue, Dec 15, 2020 at 8:04 PM Paul Sokolovsky > wrote: > > So, let's try simple yes/no questions: > > > > Example 1: > > > > a + b + c vs a + (b + c) > > > > Question 1: > > Do you agree that there's a clear difference betw

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Tue, 15 Dec 2020 08:25:25 + Jeff Allen wrote: > On 13/12/2020 22:09, Paul Sokolovsky wrote: > > Thanks for hanging with me so far, we're getting to the crux of the > > question: > > > > Do you think there can be difference between the following two > > expressions: > > > > obj.meth

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Chris Angelico
On Tue, Dec 15, 2020 at 8:49 PM Paul Sokolovsky wrote: > Right, and the question is what semantic (not implementational!) shift > happened in 3.7 (that's the point when it started to be compiled > differently). Have you read the release notes? https://docs.python.org/3/whatsnew/3.7.html#optimiza

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Steven D'Aprano
On Tue, Dec 15, 2020 at 12:04:44PM +0300, Paul Sokolovsky wrote: > I certainly agree. But the level at which I'm trying to discuss this > matter is more "abstract interpretation"'ish. For example, "+" is a > binary operator, you can't calculate "a + b + c" in one step. There're > 2 "+", and thus 2

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Mon, 14 Dec 2020 19:39:27 +1100 Steven D'Aprano wrote: > On Mon, Dec 14, 2020 at 01:09:56AM +0300, Paul Sokolovsky wrote: > > > Do you think there can be difference between the following two > > expressions: > > > > obj.meth() > > (obj.meth)() > > > > ? > > Okay, I'll bite. > >

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Chris Angelico
On Tue, Dec 15, 2020 at 8:08 PM Paul Sokolovsky wrote: > > Hello, > > On Mon, 14 Dec 2020 02:17:52 -0500 > David Mertz wrote: > > > On Sun, Dec 13, 2020, 5:11 PM Paul Sokolovsky d > > > > > a + b + c vs a + (b + c) > > > > > > Here, there's even no guarantee of the same result, if we have use

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Chris Angelico
On Tue, Dec 15, 2020 at 8:04 PM Paul Sokolovsky wrote: > So, let's try simple yes/no questions: > > Example 1: > > a + b + c vs a + (b + c) > > Question 1: > Do you agree that there's a clear difference between left and right > expression? Yes/no. Yes, there is a difference. > Example 2: > >

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Mon, 14 Dec 2020 02:17:52 -0500 David Mertz wrote: > On Sun, Dec 13, 2020, 5:11 PM Paul Sokolovsky d > > > a + b + c vs a + (b + c) > > > > Here, there's even no guarantee of the same result, if we have user > > objects with weirdly overloaded __add__(). > > > > 0.1 + 0.2 + 0.3

[Python-ideas] Re: Using explicit parenthesization to convey aspects of semantic meaning?

2020-12-15 Thread Paul Sokolovsky
Hello, On Mon, 14 Dec 2020 18:05:07 +1100 Chris Angelico wrote: > On Mon, Dec 14, 2020 at 5:57 PM Paul Sokolovsky > wrote: > > > > But that's what the question was about, and why there was the intro! > > Let's please go over it again. Do you agree with the following: > > > > a + (b + c) <=> t