Checking the type

Emile van Sebille emile at fenx.com
Wed Mar 21 07:26:49 EST 2001


There is "type" as well:

if type(a) == type(1)
if type(b) == type({})

etc

Emile van Sebille
emile at fenx.com

"Nils Hensel" <nils at hhk.de> wrote in message
news:99a539$buco$1 at ID-59026.news.dfncis.de...
> Look for the types module:
>
> from types import *
> if type(a) is ListType:
>   # do list stuff
>
> HTH,
> Nils
>
> "Markus Reitz" <Markus_Reitz at yahoo.com> schrieb im Newsbeitrag
> news:99a493$bhl$1 at sun.rhrk.uni-kl.de...
> > Hi,
> >
> > is there a possibilty to check if a variable refers to an object of type
> x?
> > Does a typeof-command exist in Python:
> >
> >   if a typeof list:
> >      #Commands only useable with list
> >
> > I read the Python Tutorial, but have not found a hint to this topic.
> >
> > Thanks
> >
> > Markus
> >
> >
>
>





More information about the Python-list mailing list