check if object is number

Mark English Mark.English at liffe.com
Mon Feb 14 06:06:34 EST 2005


Not sure if anyone's mentioned this yet, but just in case they haven't:
---- Start bit o' Python ----
>>> import operator
>>> operator.isNumberType(1)
True
>>> operator.isNumberType(1.01)
True
>>> operator.isNumberType('a')
False
>>> operator.isNumberType('1')
False
---- End bit o' Python ----
Haven't looked at the implementation (or the docs for a while) but for
everyday usage (not that I do this everyday) it's all the implementation
I need.


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies.
-----------------------------------------------------------------------




More information about the Python-list mailing list