def prefixes(s):
if s:
yield from prefixes(s[:-1])
yield s
t = prefixes('both')
next(t)
The next(t) returns 'b'. I'm just confused as to why this is because if we follow down the yield from
statement, we will eventually end at yield from prefixes('')
which would return None. In all my other tests yield from None raises a TypeError. Instead, this seems to just be ignored and prefixes('b') moves onto the next yield statement (? why does it do that?) to yield 'b'...
Any ideas as to why? Would greatly appreciate an explanation.