[Zope] Checking for an Integer Argument

Dennis Allison allison at shasta.stanford.edu
Thu Jun 30 17:08:33 EDT 2005


in Zope Python Scripts    sametype( x, 1 )



On Thu, 30 Jun 2005, Asad Habib wrote:

> Is there any way to check if an argument is an integer in Python?
> Offcourse, there is the int function but it chokes when passed an argument
> that is not a string and then the user is inconvenienced (it throws a
> ValueError to be specific). I guess I could check each digit of the
> integer to determine if its ASCII value falls within the appropriate range
> and if each digit passed this test, then the entire number would be an
> integer. Does anyone know of a simpler way that involves use of a
> predefined Python function? Likewise, does anyone know if a similar
> function exists to detect floating point numbers? Any help would be
> appreciated. Thanks.
> 
> - Asad
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
> 

-- 
Dennis Allison * Computer Systems Laboratory * Gates 227
               * Stanford University *  Stanford CA  94305
	       * (650) 723-9213 * (650) 723-0033 fax
	       * allison at shasta.stanford.edu
	       * allison at sumeru.stanford.edu




More information about the Zope mailing list