types module

Find the data type


from types import *
 # from  ww w  . ja v a 2 s  . co m
def what (x):
     if type(x) == IntType:
             print "This is an int."
     else:
             print "This is something else."
 
what(4)
what("4")

The code above generates the following result.





















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules