This also looks a lot like Out Parameters in C# ( https://www.c-sharpcorner.com/article/out-parameter-in-c-sharp-7/)
They have a similar dichotomy of declaration and call time semantics using the `out` keyword rather than an assignment operator. On Mon, Aug 26, 2019 at 10:50 AM Guido van Rossum <gu...@python.org> wrote: > I think you're talking about call-by-reference (Google it). > > What would be your use case? > > Do you know you can return multiple values from a function using a tuple? > E.g. > > def foo(): > return 3, 42 > > x, y = foo() > print(x) # 3 > print(y) # 42 > > --Guido > > On Mon, Aug 26, 2019 at 5:57 AM HUANG YUWEI <lelouchk...@gmail.com> wrote: > >> Dear Python community, >> >> I am a heavy python user in numerical simulation. >> >> In python 3.8, we will have a new syntax `:=` that could assign values to >> variables as part of larger expression like, >> >> ``` >> >> if (n:=len(a)) > 10: >> >> .... >> >> ``` >> >> On the other hand, I also think that it would be useful if `:=` could be >> used in function argument, so that a local variable created inside a >> function could be returned **optionally**, for example, >> >> ``` >> >> def func(arg1, arg2, karg1=karg1_default, karg_return:=karg_return): >> >> ... >> >> karg_return = 3 >> >> ... >> >> return func_output >> >> >> # normal calling of func() without returning variable karg_return >> >> # in this way, karg_return:=karg_return is not used and karg_return is >> only simply a local variable in func() >> >> output = func(2,3,karg1=4) >> >> >> # calling func() with using the karg_return argument >> >> # in this way, value of the local variable karg_return in func() is >> created and "passed" to variable a >> >> output = func(2,3,karg1=4,a:=karg_return) >> >> print(a) # a = 3 >> >> ``` >> >> >> Is it possible to add this new feature? >> >> >> Thanks for your attention to this matter. >> >> Huang Y.W. >> _______________________________________________ >> Python-ideas mailing list -- python-ideas@python.org >> To unsubscribe send an email to python-ideas-le...@python.org >> https://mail.python.org/mailman3/lists/python-ideas.python.org/ >> Message archived at >> https://mail.python.org/archives/list/python-ideas@python.org/message/ZN5XM5MSHAAN4U3VBAEBXUJB4ZUN6SUP/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > > > -- > --Guido van Rossum (python.org/~guido) > *Pronouns: he/him/his **(why is my pronoun here?)* > <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/RLHDDJ5CS77BWH6INCHPRR6UHEEHRGU4/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- CALVIN SPEALMAN SENIOR QUALITY ENGINEER cspea...@redhat.com M: +1.336.210.5107 [image: https://red.ht/sig] <https://red.ht/sig> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KIZDSSELN42TTWFTGHPU2KVVMRK74LJU/ Code of Conduct: http://python.org/psf/codeofconduct/