Re: iterating over DictRow

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: psycopg(at)lists(dot)postgresql(dot)org
Subject: Re: iterating over DictRow
Date: 2020-09-24 21:11:47
Message-ID: 20200924211147.GA2089@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Thu, Sep 24, 2020 at 02:53:40PM +0000, David Raymond wrote:

> Since DictRow's can be indexed by either the field name or
> the field index (either record["ID"] or record[0]) then I
> think what it "should" be is a little ambiguous.

I eventually thought so. I was, however, wondering whether I
should have _expected_ iteration over a DictRow to be a list
iteration.

Either of those

> for field in dict(the_dict):
> for field in the_dict.keys():

work, however (or RealDictCursor, for that matter).

Thanks all,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Adrian Klaver 2020-09-25 01:00:54 Re: iterating over DictRow
Previous Message Adrian Klaver 2020-09-24 15:51:52 Re: iterating over DictRow