check if object is number
Steven Bethard
steven.bethard at gmail.com
Fri Feb 11 14:48:36 EST 2005
More information about the Python-list mailing list
Fri Feb 11 14:48:36 EST 2005
- Previous message (by thread): check if object is number
- Next message (by thread): check if object is number
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dan Bishop wrote: > Steven Bethard wrote: > >>Is there a good way to determine if an object is a numeric type? > > How about this? > > ... def is_number(x): > ... try: > ... x + 1 > ... return True > ... except TypeError: > ... return False Great, thanks! That's the kind of thing I was looking for! Steve
- Previous message (by thread): check if object is number
- Next message (by thread): check if object is number
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list