Figuring out an object's type

Courageous jkraska1 at san.rr.com
Wed May 10 03:11:27 CEST 2000


David Arnold wrote:
> 
> -->"David" == David Allen <s2mdalle at titan.vcu.edu> writes:
> 
>   David> How can a python programmer figure out the type of an object?
> 
> the type() function returns the type.  if the object is a class
> instance, then it has an attribute __class__ that can be used to
> determine its class.

ergo:

import types

i=3

if type(i) == types.IntType:  print "I am an int"



More information about the Python-list mailing list