Is there a reason why this is not allowed?
return (self.mode := self.mode_valid(mode))
___
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-ide
On 2023-10-09 02:17, Dom Grigonis wrote:
Is there a reason why this is not allowed?
return (self.mode := self.mode_valid(mode))
The principal use-case for the operator is in conditions, for example:
if m := re.match(pattern_1, string):
...
elif m := re.match(pattern_2, strin
> Having:
>
>self.mode = self.mode_valid(mode)
>return self.mode
>
> isn't too bad.
No, not bad at all. But to me, being able to use walrus would be convenient.
———
This nuance can also be encountered in “principal use-case”. E.g.:
class A:
def func(self):
while (self.a :=
Dom Grigonis writes:
> This nuance can also be encountered in “principal use-case”. E.g.:
> class A:
> def func(self):
> while (self.a := 1) < 5:
> self.a += 1
> return self.a
Not sure what you're getting at here, that's an infloop. Did you mean
something li
On 9 Oct 2023, at 08:58, Stephen J. Turnbull
wrote:
> ...
> Not sure what you're getting at here, that's an infloop. Did you mean
> something like this:
>
>class A:
>def func(self):
>while (self.a := self.a += 1) < 5:
>pass
>return self.a
Mist