From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13569 invoked by alias); 7 Feb 2013 01:11:33 -0000 Received: (qmail 13538 invoked by uid 22791); 7 Feb 2013 01:11:31 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ea0-f174.google.com (HELO mail-ea0-f174.google.com) (209.85.215.174) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Feb 2013 01:11:26 +0000 Received: by mail-ea0-f174.google.com with SMTP id 1so896252eaa.33 for ; Wed, 06 Feb 2013 17:11:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=rD3uyk7QmIS0wV8KF9nGfO267KxiN/nJ2yC0SqOer1s=; b=cl/soTvYRCeog660c6Z1YXkEE3XwnU0YyN81dNJ7wfAzIFfEgrMA8x8cOquPxub4JD LJqxCPWrT+RgCWeJHqVglXDUTjtpx/k3V5ld3hJfJxpsFQpYnEye99hdPcMuYo7aUv4C ChqEYAWsYv8PQi9IKODLKXOKUAsyaoS9OZmiyJl2SQoO2zc8QSKXQWIeqAoXsBWInUs7 PzvfwNrC1OW9BGgXd1+q+vBHFgkgp70euwUIT31MrOP58oq4QlrlMiNSaVEMj8cOF8m5 JlBcCrmNra3GFk3/Z01A/4J2QgZ4eBTXvXbMT5+geO/ir7Q7U+z/x69phCaB6JCKDBkn kHyQ== MIME-Version: 1.0 X-Received: by 10.14.221.9 with SMTP id q9mr104218155eep.3.1360199484702; Wed, 06 Feb 2013 17:11:24 -0800 (PST) Received: by 10.14.100.200 with HTTP; Wed, 6 Feb 2013 17:11:24 -0800 (PST) In-Reply-To: References: <87y5f1w6xc.fsf@fleche.redhat.com> Date: Thu, 07 Feb 2013 01:11:00 -0000 Message-ID: Subject: Re: [RFC - Python Scripting] New method gdb.Architecture.disassemble From: Siva Chandra To: Matt Rice Cc: Tom Tromey , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQlsZRqLI/jEHYVXiCXc+c2+SUGCQQrjdRlIU4S+jqiVVNIZL947/OU/hSYBTZ93VRbsNsE9iE3ndBpj4XxUt2MWb2X5yCkEq2VybGPt9Ibe35kcZJ6AkEtJtCRHj7yOkl8NjmYnqcoQrko4W9P11GZs+JGcQN6SftJNgSBEOSl0uzsmXvvSAUieCr5gPLaZ3WPch593+UBEgG6tBaHoYSz1fSECNw== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00172.txt.bz2 On Wed, Feb 6, 2013 at 3:18 PM, Siva Chandra wrote: > Based on what Matt says in his comments, it seems like a leaf row can > look like one of these 3 possibilities: > > 1. [1, 2, 3] > 2. ['a' : 1, 'b': 2, 'c': 3] > 3. ['a': 1, 'a': 2, 'a': 3] > > 1 and 2 can be encapsulated with fundamental Python data structures. I > am not aware of any fundamental Python data structure which can > capture 3. So, is using a helper class called LabelValuePair a good > idea? With this, all leaf rows can be lists whose elements are either > all values, or are all LabelValuePairs: [value, value, value] or > [LabelValuePair, LabelValuePair, LabelValuePair]. Does this sound > reasonable? We can always go in for a list of single element dicts, > but I think that kind of makes it ugly. LabelValuePair can look like > this (in its Python form): > > class LabelValuePair(object): > def __init__(self, label, value): > self.label = label # not a writable attribute > self.value = value # not a writable attribute Or, could it be a named tuple: http://docs.python.org/2.7/library/collections.html#collections.namedtuple The down side is that they are available only on Python 2.4 and higher.