determine variable type

BranoZ zarnovican at gmail.com
Thu Aug 18 15:40:15 EDT 2005


Paul Rubin wrote:
> MCollins at seminolecountyfl.gov writes:
> > i tried using type(var) but that only seemed to produce a response in the
> > command line.
> >
> > is there a built in python function to determine if a variable is an
> > integer?
>
> type(var) returns the type.  For example:
>
>    if type(x) == type(3):
>       print 'x is an integer'

or

x = 5
isinstance(x, int)
True

BranoZ




More information about the Python-list mailing list