From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29657 invoked by alias); 15 Aug 2011 20:30:14 -0000 Received: (qmail 29649 invoked by uid 22791); 15 Aug 2011 20:30:13 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ausxippc101.us.dell.com (HELO ausxippc101.us.dell.com) (143.166.85.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 20:29:57 +0000 X-Loopcount0: from 10.175.216.249 From: To: CC: Date: Mon, 15 Aug 2011 20:30:00 -0000 Subject: RE: [Python] Allow attribute references to gdb.Value objects Message-ID: <09787EF419216C41A903FD14EE5506DD0151D58146@AUSX7MCPC103.AMER.DELL.COM> References: <3A56CC74-0A48-47E8-BBA2-6E2BEB2FB588@comcast.net> In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 2011-08/txt/msg00313.txt.bz2 That's a fair point, but it comes at the expense of making the code look ra= ther un-Pythonic. It seems reasonable to offer the option, and document th= e fact that code that takes advantage of it may be affected by new built-in= attributes. paul -----Original Message----- From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware= .org] On Behalf Of Tom Tromey Sent: Monday, August 15, 2011 3:10 PM To: Paul Koning Cc: gdb-patches@sourceware.org Subject: Re: [Python] Allow attribute references to gdb.Value objects >>>>> "Paul" =3D=3D Paul Koning writes: Paul> It would be more natural to be able to reference fields of a=20 Paul> gdb.Value by the standard field (attribute) syntax, e.g.,=20 Paul> "val1.field2" as opposed to "val1['field2']". The attached patch=20 Paul> does this. It acts like the Python standard method __getattr__ in=20 Paul> that it first looks for a predefined attribute (such as "type"),=20 Paul> and only if that fails will it look for a value field with the=20 Paul> given name. So val1.type means what it always did (and if you=20 Paul> want the "type" field of some structure value, you'd need to use=20 Paul> val1['type'] as before). We considered this initially, but decided on the current approach instead. = The current approach lets us add attributes to Value without breaking any = existing code. Tom