[Tutor] Type Checking:

Tim Johnson tim@johnsons-web.com
Sat, 3 Mar 2001 09:06:50 -0900


Hey Kalle:
On Sat, 03 Mar 2001, Kalle Svensson wrote:
> >%_Sez Tim Johnson:
> > Hello:
> > 	I need to be able to test the type of a variable:
> > Consider the following code:
> [snip]
> > How do I get this code to return 
> > "it's a string"
> 
> Howzabout
> >>> if type(str) == type(""):
> or
> >>> import types
> >>> if type(str) == types.StringType:
That duz it: 

and I must add:
dir(types) Displays all types:

Cool....
thnx
--
Tim Johnson
-----------
"Of all manifestations of power,
 restraint impresses the most."
 -Thucydides