Documentation, assignment in expression.
Tim Chase
python.list at tim.thechases.com
Mon Mar 26 13:42:53 EDT 2012
On 03/26/12 08:59, Thomas Rachel wrote:
> Am 25.03.2012 15:03 schrieb Tim Chase:
>> while True:
>> data = conn.fetchmany()
>> if not data: break
>> for row in data:
>> process(row)
>
> Or simpler
>
> for data in iter(conn.fetchmany, []):
> for row in data:
> process(row)
Nice! That's the first time I've seen the 2-parameter version of
iter() improve things :-) (I've seen it once or twice before in
the 2-param form, and wondered why it wasn't written in a clearer
way). Also, I was surprised to learn that the sentinel was
available as far back as 2.2 (I knew about the 1-param version as
far back as 2.3 when I became more serious about Python).
-tkc
More information about the Python-list
mailing list