any idea how i could test if a variable is a floating point number?

Oleg Broytmann phd at phd.fep.ru
Mon Jun 25 07:35:35 EDT 2001


On Mon, 25 Jun 2001, Gaz wrote:
> any idea how i could test if a variable is a floating point number?

1. Why do you need it at all? Just test if you can opertae it:

   try:
      x += 2.1
   except TypeError:
      print "Error!"

2. Well, if you still things you need to test:
   if type(x) == type(1.1): print "Yes, float"

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list