On Sat, Nov 6, 2021 at 1:06 AM one last Day <[email protected]> wrote:
>
>
> Call two or more functions with one args.
> one last Day
> إلى python-dev-owner
> قبل 7 أيام
> التفاصيل
>
> #While reading about functions in mathematics, a figure representing the sum 
> of two functions caught my attention.
> #I found it would be useful to add it in the next version of Python. Of 
> course, what is meant by collecting the two functions in mathematics is to 
> collect the results of the two functions, but here I mean to collect the two 
> or more functions on one args.
> #If all the added functions have the same parameter and the same number of 
> them, then the form x = multi (fun1,func2)(3.5) will be very useful
>
> def multi (a,b,s):
> #func to return multi func with one arg or multi args
> #Operations are performed on all parematers that represent functions using 
> one args, with the condition that all functions accept the same number of 
> variables
>
> #In this case, it is just a function that we want to develop to avoid 
> possible errors and build several scenarios
> #It has to be something like that
> # x = multi (func1,func2)(3.5)
> # and return list of func results or None for func with None return
> # print(x[0], x[1])
> a1 = a(s)
> b1 = b(s)
> return ([a1,b1])
>
> def a (s):
> #print(s)
> return s
> def b (s):
> #print(s+1)
> return s+1
>
> x = multi(a,b,2)
> print(x[0], x[1])
>

Have you tried list comprehensions?

x = [f(2) for f in (a,b)]

ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/AUDLDE7HZQID2HUF6HHLP53AWH6LTWS2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to