Michael Selik <[email protected]> writes:
> On Thu, Aug 11, 2016 at 11:46 AM Michael Selik <[email protected]>
> wrote:
>
>> On Thu, Aug 11, 2016 at 11:01 AM Steven D'Aprano <
>> [email protected]> wrote:
>>
>>> That ... looks wrong. You're taking something which looks like a procedure
>>> in the first case (trn.execute), so it probably returns None, and yielding
>>> over it. Even it that's not wrong, and it actually returned something
>>> which
>>> you ignored in the first case
>>>
>>
>> It's a standard, perhaps a mistaken standard, but nonetheless database
>> cursors tend to have that feature: execute returns the mutated self. I
>> agree that execute looks like it should return None instead. The return
>> self pattern feels Rubyish to me (or Rubic?).
>>
>
> Contradicting myself:
> yield from c.execute(query).fetchall() # looks good
> yield from c.execute(query) # looks bad
The first looks like it allocates a list to hold all the results at once
only to yield each result one by one.
How about:
c.execute(query)
yield from c
--
https://mail.python.org/mailman/listinfo/python-list