This is the mail archive of the gdb-patches@sourceware.org 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] acessing struct elements


On Wed, Aug 13, 2008 at 01:46:53AM -0300, Thiago Jung Bauermann wrote:
> There's one unexpected consequence of this: to enable the syntax above, all
> gdb.Value objects need to implement the map methods, and Python considers
> empty maps to be False in contexts which expect a boolean. Because of this,
> the following will not generally work:
> 
>     val = frame.read_var_value (sym)
>     if val:
>       print "Variable value is: " + str (val)
>     else:
>       print "Variable not found."

It took me a while to find it, but I knew there was an operator for
this.  Take a look at __nonzero__:

  http://docs.python.org/ref/customization.html

-- 
Daniel Jacobowitz
CodeSourcery


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