Checking the type

Nils Hensel nils at hhk.de
Wed Mar 21 07:01:47 EST 2001


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