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, string):
...
else:
...
or:
while line := file.readline():
...
Do you have a convincing argument that it should be expanded from a
simple name?
Having:
self.mode = self.mode_valid(mode)
return self.mode
isn't too bad.
_______________________________________________
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/OIZ3W7XOIAFU345FKXN63YOC2J7E4R5I/
Code of Conduct: http://python.org/psf/codeofconduct/