Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-11 Thread Rhodri James
On 07/11/2019 13:36, Stephen Waldron wrote: This is how it is at the moment, however it may be more agreeable, especially if that is the only purpose of the function, for python users to be able to define new functions inside of function calls. No, not seeing it. Sorry, I don't think "I don'

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Stephen Waldron
Ok firstly, this idea was inspired specifically by a project I'm working on for school concerning linked lists, in which I was trying to create a method that performed a function on elements iteratively without having to navigate the list from the head each time (of course taking the function as

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Chris Angelico
On Fri, Nov 8, 2019 at 11:22 PM Antoon Pardon wrote: > > On 8/11/19 13:00, Chris Angelico wrote: > > On Fri, Nov 8, 2019 at 10:57 PM Antoon Pardon wrote: > >> On 7/11/19 18:10, Stephen Waldron wrote: > >>> What I'm aiming for is the ability to, within a function call, pass a > >>> suite that wou

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Antoon Pardon
On 8/11/19 13:00, Chris Angelico wrote: > On Fri, Nov 8, 2019 at 10:57 PM Antoon Pardon wrote: >> On 7/11/19 18:10, Stephen Waldron wrote: >>> What I'm aiming for is the ability to, within a function call, pass a suite >>> that would be there automatically defined by the compiler/interpreter. >>

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Chris Angelico
On Fri, Nov 8, 2019 at 10:57 PM Antoon Pardon wrote: > > On 7/11/19 18:10, Stephen Waldron wrote: > > What I'm aiming for is the ability to, within a function call, pass a suite > > that would be there automatically defined by the compiler/interpreter. > > Another comment did mention lambda func

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Antoon Pardon
On 7/11/19 18:10, Stephen Waldron wrote: > What I'm aiming for is the ability to, within a function call, pass a suite > that would be there automatically defined by the compiler/interpreter. > Another comment did mention lambda functions, which does to some degree > provide that capability, but

RE: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread David Raymond
Here is it rewritten using the proposal: ``` #Definition def myFoo (str1, str2, foo, str = " "): print( foo(str = str1), foo(str = str2) ) #Call myFoo ("hello", "world!"): str = list(str)[0].upper() + str[1:] return str ``` Are you looking for multi-line l

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to "reference its [the function's] name" as an argument, however the point I was trying to make was that it isn't possible to pass a function that is either not in some way previously defined or a reference to something

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to "reference its [the function's] name" as an argument, however the point I was trying to make was that you cannot pass a function that is either not in some way previously defined or a reference to something previously

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Antoon Pardon
On 7/11/19 14:36, Stephen Waldron wrote: > Hi, I'm new to the group and to Python, so forgive me if I make any faux-pas > here. As I can tell, the only way to pass a function as an argument is to > reference its name as follows: > > def foo1(message): > print(message) > > def foo2(foo, messag

Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Hi, I'm new to the group and to Python, so forgive me if I make any faux-pas here. As I can tell, the only way to pass a function as an argument is to reference its name as follows: def foo1(message): print(message) def foo2(foo, message): print("Your function says:") foo(message)