---------- Forwarded message ---------- From: Hugo Arts <[email protected]> Date: Wed, Jun 1, 2011 at 12:01 AM Subject: Re: [Tutor] checking if a variable is an integer? To: Peter Lavelle <[email protected]>
On Tue, May 31, 2011 at 11:46 PM, Peter Lavelle <[email protected]> wrote: > I think you could also use the type() function. See example below: > > if type(yourvar) == int: > #Do stuff here if it is an integer > > else: > #Do something here if it is not an integer > I think the isinstance() function is preferred since it also catches subclasses: http://docs.python.org/library/functions.html#isinstance Hugo _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
