Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLTXP-0005Vb-Ai for psycopg@arkaria.postgresql.org; Thu, 24 Sep 2020 15:52:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kLTXN-0003xY-Rx for psycopg@arkaria.postgresql.org; Thu, 24 Sep 2020 15:52:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLTXM-0003xQ-5K for psycopg@lists.postgresql.org; Thu, 24 Sep 2020 15:52:01 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLTXI-00066S-9J for psycopg@lists.postgresql.org; Thu, 24 Sep 2020 15:51:59 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8F0575C0045; Thu, 24 Sep 2020 11:51:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 24 Sep 2020 11:51:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=Q Vrd1WHmYa+P4oLr5SsHK7flvELzlGMa3NFUUPwMntY=; b=bm6Q0RTlJWxBUNshI KOqHd717uOSyW29AF8SpT5jPLvC0lndm+zq6N6d9K8xTBnVIkxURBa3azrATI5Nv jRF7SWoPn3YLDyqV80HD1v3VtwCqcZ38XkBjTTVpN8+OT3d/7jV+yaLPZYjEU7MO iLXOXJZrjTvGYqCCkNtBKFHH0VGN7ggddcsTv/f+L1sDnbuG9EWHljf5wk22RQOv T3Ea8H0eWKEtyLVy8hDZO8a8SA8CZOqTLDr0K/kM7ONyYITT4W+0ANCma/HszSYX gD/jcj/FQu2SXZL6Uf9HNUnlTA1EiViU7uKFqiABZIMHtVfm+niBTRjChs+MQM6W ZiOpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=QVrd1WHmYa+P4oLr5SsHK7flvELzlGMa3NFUUPwMn tY=; b=bzyWAP9ryuYRAZ2IuEHPXQpR7gKCI2ye/vZTIC27VW04upy2OyQhcY+M2 OXpjmC3GOqavnKP0/lD3W8D/1p3VnVgu05ZFabbh5OXMfKnFLHWG7lmTDYmxZyUh 7FAv0rQeOwWr9AbZUHA5foX4X2QtS2TPy1nSU8KnADuxZz2JsmQOtMD0WIM3Gv6w 9fwfRYpM//0+tPtiseze/l2UkGxsW2zJtl/fdYOhuhvflGPOoaxoMSeE054Aa72q 2LJXqLoqR009NkboI2rKXkznJGwTOrrEUuBivZkSQMQbUSlAmMY6P55F/K+PrFRN kFKzwfak0BYYqy5laEqxtBbB5ADrw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudekgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepteejvdetffejuedvleeifeefheeutdfhgfdvhffhhfek vdduveegvdejudefgfevnecukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id E8B213064683; Thu, 24 Sep 2020 11:51:52 -0400 (EDT) Subject: Re: iterating over DictRow To: David Raymond , "psycopg@lists.postgresql.org" References: <20200923215444.GA25406@hermes.hilbert.loc> From: Adrian Klaver Message-ID: <7b2272a8-de4d-bc95-1efc-84d69ea7c4c1@aklaver.com> Date: Thu, 24 Sep 2020 08:51:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/24/20 7:53 AM, 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. But you can always either cast it to a dict, or iterate over .keys() if you want the field names. > > for field in dict(the_dict): > ... > or > for field in the_dict.keys(): > ... > Except I think the_dict is actually the_list. I was just about to post a reply to my post saying that my use of the_dict was incorrect as I was actually iterating over a list. -- Adrian Klaver adrian.klaver@aklaver.com