I can't figure out how to test a variable n for its type.

An example that is the wrong syntax, but shows what I want to do:

if type(n) == 'int' or type(n) == 'long':
   do something

elif type(n) == 'float':
   do something else

elif type(n) == 'str':
   do something different

What's the correct way?

Thanks,

Dick Moores

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to