From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25905 invoked by alias); 17 Aug 2010 10:59:33 -0000 Received: (qmail 25896 invoked by uid 22791); 17 Aug 2010 10:59:32 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ausc60ps301.us.dell.com (HELO ausc60ps301.us.dell.com) (143.166.148.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Aug 2010 10:59:28 +0000 X-Loopcount0: from 10.152.240.141 Subject: Re: doing a comparison in python Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Paul Koning In-Reply-To: <1282009231.2624.37.camel@hactar> Date: Tue, 17 Aug 2010 10:59:00 -0000 Cc: Mathew Yeates , Michael Snyder , "gdb@sourceware.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <4C69D737.1080200@vmware.com> <1282009231.2624.37.camel@hactar> To: Thiago Jung Bauermann X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00111.txt.bz2 On Aug 16, 2010, at 9:40 PM, Thiago Jung Bauermann wrote: > On Mon, 2010-08-16 at 17:34 -0700, Mathew Yeates wrote: >> On Mon, Aug 16, 2010 at 5:26 PM, Michael Snyder wro= te: >>> Mathew Yeates wrote: >>>> I am debugging fortran code and I want to see if an interior value is >>>> equal to .FALSE. >>>> I know how to get the value with parse_and_eval but what do I do with = it? >>>=20 >>> Can we assume this value is an integer? >>> Then you should be able to do something like this: >>>=20 >>> long foo =3D value_as_long (parse_and_eval (my_value)); >>>=20 >>> if (foo =3D=3D 0) >>> [...]; >>=20 >> no. it's a logical. Either .TRUE. or .FALSE. >=20 > GDB values in Python scripts can be directly compared with Python's > native types, so you can just say: >=20 > foo =3D gdb.parse_and_eval ("foo") > if foo =3D=3D True: > print 'hooray' > --=20 That's a bit redundant, just as it would be in C. I would write: foo =3D gdb.parse_and_eval ("foo") if foo: print 'hooray' -- paul