> Yes, but what if you're testing for something that could *potentially* match 
> one of these empty objects?

The right side can absolutely be falsy but to be able to conflate the falsy 
return value with the None emitted when the pattern doesn't match, the left 
side has to be one of the dubious patterns I listed.

> I'm worried that this will end up being a bug magnet, or conversely, that 
> people will have to work around it with "if ([x] := foo()) is not None:", 
> which is way too clunky.

In your example "if ([x] := foo()) is not None:" there is no possible value 
returned by foo() that could be both falsy and match the [x] pattern at the 
same time. All patterns besides the ones I listed can only be matched by truthy 
values so the work-around would only be needed for those dubious patterns.

I think I'll experiment with a prototype when I have more time.
_______________________________________________
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/VFRVYISEETRVZE6ODA72L7I3V63M6KY7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to