This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [Python] Allow attribute references to gdb.Value objects

That's a fair point, but it comes at the expense of making the code look rather un-Pythonic.  It seems reasonable to offer the option, and document the fact that code that takes advantage of it may be affected by new built-in attributes.


-----Original Message-----
From: [] On Behalf Of Tom Tromey
Sent: Monday, August 15, 2011 3:10 PM
To: Paul Koning
Subject: Re: [Python] Allow attribute references to gdb.Value objects

>>>>> "Paul" == Paul Koning <> writes:

Paul> It would be more natural to be able to reference fields of a 
Paul> gdb.Value by the standard field (attribute) syntax, e.g., 
Paul> "val1.field2" as opposed to "val1['field2']".  The attached patch 
Paul> does this.  It acts like the Python standard method __getattr__ in 
Paul> that it first looks for a predefined attribute (such as "type"), 
Paul> and only if that fails will it look for a value field with the 
Paul> given name.  So val1.type means what it always did (and if you 
Paul> want the "type" field of some structure value, you'd need to use 
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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]