> In 3.8, foo(a := 42) is in fact valid syntax, meaning the same as foo((a
> := 42)).
>
Yes, I ignored that assign operator is actually a valid syntax in function
calling, and what I need is new syntax.
Although the "dynamic return" could be implemented, I agree that it is
unworthy and
HUANG YUWEI wrote:
the number of return variables could be many. Then it would look like
```
res0, res1, res2, res3, res4, res5, res6, res7, ..., resN =
high_level_function()
At that point you're better off returning an object with named
attributes, such as a namedtuple or a class designed
HUANG YUWEI wrote:
# calling func() with using the karg_return argument
output = func(2,3,karg1=4,a:=karg_return)
This would be ambiguoius, because a:=karg_return is valid as an
ordinary expression with an embedded assignment.
--
Greg
___
On Aug 26, 2019, at 10:51, Guido van Rossum wrote:
>
> I'd love to squash this conversation (because I don't think it'll lead
> anywhere) but you've nerd-sniped me a little bit.
Well, you started it by saying it was impossible. :)
>
> In 3.8, foo(a := 42) is in fact valid syntax, meaning the
I'd love to squash this conversation (because I don't think it'll lead
anywhere) but you've nerd-sniped me a little bit.
In 3.8, foo(a := 42) is in fact valid syntax, meaning the same as foo((a :=
42)).
If you wanted to do this with explicit syntax, you can just pass any
mutable object. We have
On Aug 26, 2019, at 08:38, Guido van Rossum wrote:
>
> Sorry, there is no way to leverage the implementation or syntax of := for
> this purpose. You must be misunderstanding how they it works.
>
> You are right that the initial value of the variable at the call site is
> irrelevant (but there
Dear Mr. Guido,
Ok, I see.
Thank you for your prompt reply.
Best regards,
Huang Y.W
Guido van Rossum 于2019年8月27日周二 上午12:38写道:
> Sorry, there is no way to leverage the implementation or syntax of := for
> this purpose. You must be misunderstanding how they it works.
>
> You are right that the
Sorry, there is no way to leverage the implementation or syntax of := for
this purpose. You must be misunderstanding how they it works.
You are right that the initial value of the variable at the call site is
irrelevant (but there must be some initial value, e.g. None, to be able to
identify the
Dear Mr. Guido and Mr. Spealman,
Thanks for your quick reply.
Yes, something like "Out Parameters in C#" is exactly what I mentioned.
"calling by reference" is very close, except that
- with "calling by reference", the object is initialized before the
function is called, and then being passed
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
10 matches
Mail list logo