<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2900.3354" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=022582402-07082008>#this 
is a better way of testing a string for float</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=022582402-07082008>def 
isFloat(s):</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=022582402-07082008>    try:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=022582402-07082008>        s = 
float(s)</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=022582402-07082008>    except:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=022582402-07082008>        return 
False</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=022582402-07082008>    return True</SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Madari, Edwin 
  <BR><B>Sent:</B> Wednesday, August 06, 2008 10:22 PM<BR><B>To:</B> 'Wei Guo'; 
  python-list@python.org<BR><B>Subject:</B> RE: A question about string and 
  float number<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=534332002-07082008>type(s) == type(float())</SPAN></FONT></DIV>
  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
    <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
    size=2>-----Original Message-----<BR><B>From:</B> 
    python-list-bounces+edwin.madari=verizonwireless.com@python.org 
    [mailto:python-list-bounces+edwin.madari=verizonwireless.com@python.org]<B>On 
    Behalf Of </B>Wei Guo<BR><B>Sent:</B> Wednesday, August 06, 2008 9:23 
    PM<BR><B>To:</B> python-list@python.org<BR><B>Subject:</B> A question about 
    string and float number<BR><BR></FONT></DIV>
    <DIV>Hi all,</DIV>
    <DIV> </DIV>
    <DIV>I am new of python. Could anyone help me a question as below?</DIV>
    <DIV> </DIV>
    <DIV>Is there any function that can judge a string s is a float number 
    or not? FOr example, if s = '1.232' or s='1e+10', then it returns true, 
    otherwise, it will return false.</DIV>
    <DIV> </DIV>
    <DIV>isdigit() in string doesn't work. float() will throw an exception and I 
    just need true or false as result.</DIV>
    <DIV> </DIV>
    <DIV>Thanks a lot in advance,</DIV>
    <DIV> </DIV>
    <DIV>Wei</DIV></BLOCKQUOTE></BLOCKQUOTE><pre>

The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

</pre></BODY></HTML>