[Tutor] taking support of strings in solving numerical problems
Cameron Simpson
cs at cskk.id.au
Mon Oct 26 05:35:54 EDT 2020
On 26Oct2020 08:06, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
>On 26/10/2020 04:55, Cameron Simpson wrote:
>>> def ser_gen(no, order):
>>> f_no = no
>>> for i in range(order):
>>> yield f_no
>>> f_no = f_no*10 + no
>>>
>>> all(ser_gen(9, -3)) Returns True that says, there is an empty iterable
>>> inside all( )
>>
>> Returns True for me, too. Which is expected behaviour.
>>
>> It is not clear to me what your objection is about.
>
>To be honest it surprised me too. I expected the function to fall
>off the bottom and return none. But in fact it raises a
>StopIteration instead, which all() interprets as an empty sequence.
It didn't surprise me. It is just end of execution of a generator function.
This is why I couldn't see what Manprit is concerned about.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list