[Zope] Python Function to Test for Integer Type
Paul Winkler
pw_lists at slinkp.com
Tue Jun 15 17:03:00 EDT 2004
On Tue, Jun 15, 2004 at 02:00:35PM -0400, Asad Habib wrote:
> Hello. Does anyone know of a python function that returns a value based on
> whether or not its argument is an integer? Any help would be greatly
> appreciated. Thanks.
pretty trivial to roll your own... I'm assuming you also want
it to return true for longs:
import types
def is_int(arg):
return type(arg) in (types.IntType, types.LongType)
In zope's Script (Python), you can't do that because type() is not
allowed; but you can make do with the same_type function:
return same_type(arg, 1) or same_type(arg, 1L)
--
Paul Winkler
http://www.slinkp.com
More information about the Zope
mailing list