Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-03 Thread Alexey Muranov
On mer., Apr 3, 2019 at 6:00 PM, python-list-requ...@python.org wrote: On Wed, Apr 3, 2019 at 3:55 AM Alexey Muranov wrote: I clarified what i meant by an assignment, and i believe it to be a usual meaning. 1. `def` is not an assignment, there is no left-hand side or right-hand side. I w

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Chris Angelico
On Wed, Apr 3, 2019 at 3:55 AM Alexey Muranov wrote: > I clarified what i meant by an assignment, and i believe it to be a > usual meaning. > > 1. `def` is not an assignment, there is no left-hand side or > right-hand side. I was talking about the normal assignment by which > anyone can bind any

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Alexey Muranov
On mar., Apr 2, 2019 at 6:00 PM, python-list-requ...@python.org wrote: On Tue, Apr 2, 2019 at 1:43 AM Alexey Muranov wrote: > On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov gmail.com> > wrote: > > > > I only see a superficial analogy with `super()`, but perhaps it is > > because you

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Tue, Apr 2, 2019 at 1:43 AM Alexey Muranov wrote: > > > On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov > gmail.com> > > wrote: > > > > > > I only see a superficial analogy with `super()`, but perhaps it is > > > because you did not give much details of you suggestion. > > > > No, it's because t

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Alexey Muranov
On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov gmail.com> wrote: > > I only see a superficial analogy with `super()`, but perhaps it is > because you did not give much details of you suggestion. No, it's because the analogy was not meant to be anything more than superficial. Both are constructs of

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Chris Angelico
On Tue, Apr 2, 2019 at 6:04 PM Ian Kelly wrote: > > Note that > > > > foo.bar = baz > > > > and > > > > foo[bar] = baz > > I wrote "directly assigned to a variable", not to an attribute or an item. > These are not part of the suggestion. So what's the advantage over just using def? Chris

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov wrote: > > I only see a superficial analogy with `super()`, but perhaps it is > because you did not give much details of you suggestion. No, it's because the analogy was not meant to be anything more than superficial. Both are constructs of syntactic

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-01 Thread Alexey Muranov
On lun., avril 1, 2019 at 6:00 PM, python-list-requ...@python.org wrote: On Sun, Mar 31, 2019 at 1:09 PM Alexey Muranov wrote: On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote: > On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov > > wrote: > >> >> On ven., Mar 29,

RE: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-01 Thread Schachner, Joseph
, saying that it is a generator and describing what it does. I realize I'm calling on the programmer to address this issue by adding doc strings. Nonetheless adding doc strings is a good habit to get in to. --- Joseph S. -Original Message----- From: Ian Kelly Sent: Sunday, March 31,

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Ian Kelly
On Sun, Mar 31, 2019 at 1:09 PM Alexey Muranov wrote: > > On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote: > > On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov > > > > wrote: > > > >> > >> On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org > >> wrote: > >> > > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Alexey Muranov
On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote: On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov wrote: On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org wrote: > > There could perhaps be a special case for lambda expressions such > that, > when the

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-30 Thread Ian Kelly
On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov wrote: > > On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org wrote: > > > > There could perhaps be a special case for lambda expressions such > > that, > > when they are directly assigned to a variable, Python would use the > > variable

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-30 Thread Alexey Muranov
On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org wrote: On Thu, Mar 28, 2019 at 2:30 PM Alexey Muranov  wrote: On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: > Throwing the name away is foolish. Testing functions is another > situation in which function names

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-29 Thread Antoon Pardon
On 27/03/19 09:21, Alexey Muranov wrote: > Whey you need a simple function in Python, there is a choice between a > normal function declaration and an assignment of a anonymous function > (defined by a lambda-expression) to a variable: > >    def f(x): return x*x > > or > >    f = lambda x: x*x > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Terry Reedy
On 3/28/2019 12:29 PM, Alexey Muranov wrote: On jeu., Mar 28, 2019 at 5:00 PM, python-list-requ...@python.org wrote: So my opinion is that lambda expressions should only be used within larger expressions and never directly bound. It would be however more convenient to be able to write inste

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Chris Angelico
On Fri, Mar 29, 2019 at 7:29 AM Alexey Muranov wrote: > My idea however was to have it as an exact synonyme of an assignment of > a lambda. Assignment is an assignment, it should not modify the > attributs of the value that is being assigned. Assigning lambda functions to names generally shouldn'

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Thu, Mar 28, 2019 at 2:30 PM Alexey Muranov wrote: > > On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: > > Throwing the name away is foolish. Testing functions is another > > situation in which function names are needed for proper report. > > My idea however was to have it as an exact s

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Alexey Muranov
On jeu., mars 28, 2019 at 5:00 PM, python-list-requ...@python.org wrote: So documentation of that syntax would 100% be required Regarding documentation, i believe there would be 3 line to add: () = is a syntactic sugar for = lambda : Alexey. -- https://mail.python.org/mailman

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Alexey Muranov
On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: On 3/28/2019 12:29 PM, Alexey Muranov wrote: On jeu., Mar 28, 2019 at 5:00 PM, python-list-requ...@python.org wrote: So my opinion is that lambda expressions should only be used within larger expressions and never directly bound. It w

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Alexey Muranov
On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: But i see your point about never assigning lambdas directly, it makes sense. But sometimes i do assign short lambdas directly to variable. Is the convenience and (very low) frequency of applicability worth the inconvenience of confu

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Alexey Muranov
On jeu., mars 28, 2019 at 5:00 PM, python-list-requ...@python.org wrote: On 2019-03-27 10:42 a.m., Paul Moore wrote: On Wed, 27 Mar 2019 at 12:27, Alexey Muranov wrote: On mer., mars 27, 2019 at 10:10 AM, Paul Moore wrote: On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: Whey yo

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Wed, Mar 27, 2019 at 3:13 AM Paul Moore wrote: > > On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: > > > > Whey you need a simple function in Python, there is a choice between a > > normal function declaration and an assignment of a anonymous function > > (defined by a lambda-expression) t

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Alexey Muranov
On jeu., Mar 28, 2019 at 5:00 PM, python-list-requ...@python.org wrote: So my opinion is that lambda expressions should only be used within larger expressions and never directly bound. It would be however more convenient to be able to write instead just f(x) = x*x Given my view above,

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Antoon Pardon
On 27/03/19 22:25, Terry Reedy wrote: > ... > > Before 3.8, I would stop here and say no to the proposal.  But we now > have assignment expressions in addition to assignment statements. > > >>> int(s:='42'+'742') > 42742 > >>> s > '42742' > > To me, function assignment expressions, as a enhanced re

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Ben Finney
Alexey Muranov writes: > It would be however more convenient to be able to write instead just > >f(x) = x*x That's not an anonymous function then, is it? You want to assign a name to that function, and (to be useful in development tools, such as a stack trace) the function needs to know its

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Terry Reedy
On 3/27/2019 4:21 AM, Alexey Muranov wrote: Whey you need a simple function in Python, there is a choice between a normal function declaration and an assignment of a anonymous function (defined by a lambda-expression) to a variable:    def f(x): return x*x or    f = lambda x: x*x PEP 8 p

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Alexey Muranov
On mer., Mar 27, 2019 at 5:00 PM, python-list-requ...@python.org wrote: On 27/03/19 09:21, Alexey Muranov wrote: Whey you need a simple function in Python, there is a choice between a normal function declaration and an assignment of a anonymous function (defined by a lambda-expression) to a

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Alexandre Brault
On 2019-03-27 10:42 a.m., Paul Moore wrote: > On Wed, 27 Mar 2019 at 12:27, Alexey Muranov wrote: >> On mer., mars 27, 2019 at 10:10 AM, Paul Moore >> wrote: >>> On Wed, 27 Mar 2019 at 08:25, Alexey Muranov >>> wrote: Whey you need a simple function in Python, there is a choice betwee

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Rhodri James
On 27/03/2019 16:15, Bev in TX wrote: On Mar 27, 2019, at 10:41 AM, Antoon Pardon wrote: I don't know. Something like the following is already legal: f(x)[n] = x * n And it does something completly different. Where would I find information on what this does in the documentation? Nowhere

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Bev in TX
> On Mar 27, 2019, at 10:41 AM, Antoon Pardon wrote: > > I don't know. Something like the following is already legal: > > f(x)[n] = x * n > > And it does something completly different. Where would I find information on what this does in the documentation? Bev in TX -- https://mail.pytho

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Antoon Pardon
On 27/03/19 09:21, Alexey Muranov wrote: > Whey you need a simple function in Python, there is a choice between a > normal function declaration and an assignment of a anonymous function > (defined by a lambda-expression) to a variable: > >    def f(x): return x*x > > or > >    f = lambda x: x*x > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Paul Moore
On Wed, 27 Mar 2019 at 12:27, Alexey Muranov wrote: > > On mer., mars 27, 2019 at 10:10 AM, Paul Moore > wrote: > > On Wed, 27 Mar 2019 at 08:25, Alexey Muranov > > wrote: > >> > >> Whey you need a simple function in Python, there is a choice > >> between a > >> normal function declaration and

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Alexey Muranov
On mer., mars 27, 2019 at 10:10 AM, Paul Moore wrote: On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: Whey you need a simple function in Python, there is a choice between a normal function declaration and an assignment of a anonymous function (defined by a lambda-expression) to

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Paul Moore
On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: > > Whey you need a simple function in Python, there is a choice between a > normal function declaration and an assignment of a anonymous function > (defined by a lambda-expression) to a variable: > > def f(x): return x*x > > or > > f = l