[Tutor] Integer?

Mike Hansen Mike.Hansen at atmel.com
Wed Dec 6 16:04:54 CET 2006

> > How can I check if a variable is an integer?
> Luke and John have answered your question, but we should also 
> ask, why 
> do you want to do that? Explicit type testing is a code 
> smell, perhaps 
> there is a better way to do what you want.
> Kent


Can you explain further? Refactoring is in my queue of books to read. In
a web app I'm writing, I'm checking the input kind of like this...

	form_value = int(form.getvalue('num_widgets')
except ValueError:
	display_error("Number of Widgets must be a number")

-------------- next part --------------

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or entity.

  Its contents may be privileged, confidential, and exempt from disclosure under the law.
  Any dissemination, distribution, or copying of this communication is strictly prohibited.

  Please notify the sender immediately if you are not the intended recipient.


More information about the Tutor mailing list