Yield after the return in Python function.

Chris Angelico rosuav at gmail.com
Wed Apr 7 08:42:04 EDT 2021


On Wed, Apr 7, 2021 at 10:30 PM Stestagg <stestagg at gmail.com> wrote:
>
>
>
> On Wed, Apr 7, 2021 at 12:31 PM Chris Angelico <rosuav at gmail.com> wrote:
>>
>>
>> I just realised that the whole eval/exec/namespace stuff is massive
>> overkill. All you need is an object that is inconsistent in its
>> boolification...
>>
>
> Somewhat related: https://bugs.python.org/issue42899
>

Yup. There are a very few edge cases where pathological behaviour can
be optimized out. Sometimes, there's an alternative way to describe it
(for example, containment is defined as "identity or equality"), but
other times, you can't actually pin down the exact semantics in Python
code. Or maybe it's possible, but really hard; the precise meaning of
"yield from iterable" is quite the read - check out PEP 380, and
notice that even just calling a method isn't as simple as it looks :)

ChrisA


More information about the Python-list mailing list