Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assumed': 0.09; 'cc:addr :python-list': 0.11; 'assume': 0.14; "wouldn't": 0.14; 'dict': 0.16; 'subject:Convert': 0.16; 'tuple': 0.16; "{'a':": 0.16; 'sender:addr:gmail.com': 0.17; 'thanks,': 0.17; 'wrote:': 0.18; 'thanks.': 0.20; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'example.': 0.24; 'refers': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'getting': 0.31; 'tuples': 0.31; 'operate': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'that,': 0.38; 'first': 0.61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=xO/V5ShGoOB4G63MNmKYDHaZuNIdj8fI93sdGSKa7wI=; b=XjFM02E7uelaB2RgdMYybHLKygxs10HMrQhReoXoKRqAU9GxBEwTW464IAUjSYx1Or rIiUEHzj+9WcDbHU+aH21gz1y8kJdUIaxyvFx/ZFw289jNhTw512cfCqdci3YqdH/ooc liIh7dZBYkU0slGb3/9BY/gS+MXf6T7Mys4eU4XRnJjKU+w8+L6T4uNRps/d+Lv3Z/Wi lC1VeNlQ4nU7UggKOKNlO1vyOOSb9Ec7ZxW6Ft2ls0jOE+hwRbRRczoh9/u3wLBOI/hu T83egshD0TGCvN9xR6knzpD4PdV5ZnpS+Pcp6346OOayqfBN51wfuYI/Axswh+hF1SnP kbuA== X-Received: by 10.221.44.136 with SMTP id ug8mr1678514vcb.13.1380217380371; Thu, 26 Sep 2013 10:43:00 -0700 (PDT) Sender: Ned Batchelder Date: Thu, 26 Sep 2013 13:42:59 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Virendra Tripathi Subject: Re: Convert namedtuple to dictionary References: <6962B501-781B-4D05-93C6-50E3FFBAE9A4@maansystems.com> In-Reply-To: <6962B501-781B-4D05-93C6-50E3FFBAE9A4@maansystems.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380217388 news.xs4all.nl 15989 [2001:888:2000:d::a6]:52443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54844 On 9/26/13 1:17 PM, Virendra Tripathi wrote: > Hi Ned, > > Thanks. Wouldn't I have to first create a function to pull out the 'dictdict' from the data? I assume 'dictdict' refers to the 'brucelee' named tuple in the example. That's where I was getting stuck-trying to pull out the named tuples from the dict and operate on it. I assumed you already had the data you showed. This is tupledict: {'a': brucelee(x=123, y=321), 'b': brucelee('x'=123, 'y'=321) Given that, you create dictdict with the line I showed: dictdict = { k: nt._asdict() for k, nt in tupledict } > Thanks, > > Virendra