Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-23 Thread Bruce Leban
On Wed, Jan 23, 2019 at 1:07 PM James Lu wrote: > Backtick expressions (now) use the same scoping and same binding rules as > other functions. > What do you mean by "now"?? There are no backtick expressions in Python anymore and they were never functions. > The only difference is that > class

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-23 Thread Christopher Barker
> > > The only thing that I can think of is that you want `foo + ^bar` to be > another way of writing lambda bar: foo + bar with some under-specified > behavior > for evaluating foo and different under-specified behavior for evaluating > bar. > > That is what `lambda bar: foo + ^bar` means. >

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-23 Thread James Lu
Backtick expressions (now) use the same scoping and same binding rules as other functions. The only difference is that class Class: stacticmethod = `...` staticmethod = lambda: ... def instancemethod = `...` # an instancemethod that's called with self passed in def property =

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-23 Thread Bruce Leban
On Sun, Jan 20, 2019 at 6:43 PM James Lu wrote: > Backtick expressions work exactly like lambdas, except that they are bound > to the instance they are created in every time that class is used to create > one. To illustrate, ... First, if there is a useful procedure I am strongly against using

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Steven D'Aprano
On Mon, Jan 21, 2019 at 05:56:17PM +1100, Steven D'Aprano wrote: [...] > > Variable names that are declared but have not been assigned to will be > > considered to exist for the purposes of the backtick expression. > > Python doesn't have variable declarations, so I don't know what this >

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Stephen J. Turnbull
Jonathan Fine writes: > > Backtick expressions work exactly like lambdas, except that they > > are bound to the instance they are created in every time that > > class is used to create one. > > I would if possible very much like to see some real world examples of > Python code, that would

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Christopher Barker
Going back to the original post: On Sun, Jan 20, 2019 at 6:43 PM James Lu wrote: > Backtick expressions work exactly like lambdas, except that they are bound > to the instance they are created in every time that class is used to create > one. ?!? bound every time that instance is used to

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Barry Scott
The problem with using the back-tick is that it is far too easy to miss read it for a single-quote. back-tick in bash has the $( xxx ) replacement that avoids the problem. Please find an alternative syntax that avoid the problem. Barry > On 22 Jan 2019, at 13:42, James Lu wrote: > > Later

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Stephan Hoyer
On Mon, Jan 21, 2019 at 8:47 AM Jonathan Fine wrote: > > Backtick expressions work exactly like lambdas, except that they are > bound to the instance they are created in every time that class is used to > create one. > > I would if possible very much like to see some real world examples of >

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread James Lu
I’m a little busy recently, so I’ll reply to as much as I can now and reply to the rest later. Scratch the stuff I said about scope. Backtick expressions should inherit the scope normally like any other nested function. > That's different behaviour from regular functions, where names are only

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread James Lu
Later today I will send a working implementation of backtick expressions as a function call. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread James Lu
> On Jan 21, 2019, at 1:56 AM, Steven D'Aprano wrote: > > It disturbs me that you believe you get to tell everyone what syntax > highlighting they should use for this feature. That's pretty > dictatorial, and not in a good BDFL way. I don’t want to tell anyone how to make their syntax

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread James Lu
> On Jan 21, 2019, at 1:56 AM, Steven D'Aprano wrote: > > It disturbs me that you believe you get to tell everyone what syntax > highlighting they should use for this feature. That's pretty > dictatorial, and not in a good BDFL way. I don’t want to tell anyone how to make their syntax

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-21 Thread Greg Ewing
Calvin Spealman wrote: The one positive I see is that because there is no open and closing pair of backticks, like parens or brackets, you can't easily nest this syntax and I actually like how it inherently discourages or makes that impossible! Perhaps surprisingly, the backtick syntax in

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-21 Thread Steven D'Aprano
On Mon, Jan 21, 2019 at 05:56:17PM +1100, Steven D'Aprano wrote: [...] > > And a few more examples for clarity. > > > > def example(): > > locals()['a'] = 1 > > expr = `a+1` > > return expr() # error: one variable is required > > Still not clear to me. It might help if you showed expected input

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-21 Thread Jonathan Fine
> Backtick expressions work exactly like lambdas, except that they are bound to > the instance they are created in every time that class is used to create one. I would if possible very much like to see some real world examples of Python code, that would benefit by being rewritten to use the new

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-21 Thread Calvin Spealman
On Sun, Jan 20, 2019 at 9:43 PM James Lu wrote: > Backtick expressions work exactly like lambdas, except that they are bound > to the instance they are created in every time that class is used to create > one. To illustrate, this “percent” property is bound to the instance, not > to the class. >

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-20 Thread Steven D'Aprano
On Sun, Jan 20, 2019 at 07:21:50PM -0500, James Lu wrote: > Backtick expressions work exactly like lambdas, except that they are > bound to the instance they are created in every time that class is > used to create one. To illustrate, this “percent” property is bound to > the instance, not to