<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Determine Whether a String Value is Numeric in Python</title>
	<atom:link href="http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/feed" rel="self" type="application/rss+xml" />
	<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html</link>
	<description>Tips and short tutorials on various programming technologies</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:17:05 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: File077</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-481</link>
		<dc:creator>File077</dc:creator>
		<pubDate>Fri, 25 Jun 2010 12:27:19 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-481</guid>
		<description>Wow guys..

def is_numeric(val):
  try:
    float(val)
  except ValueError, e:
    return False
  return True

&quot;.-02&quot; FALSE
&quot;-.02&quot; TRUE
&quot;.02.&quot; FALSE
&quot;02.-&quot; FALSE
&quot;0.00&quot; True
&quot;-1.2&quot; TRUE</description>
		<content:encoded><![CDATA[<p>Wow guys..</p>
<p>def is_numeric(val):<br />
  try:<br />
    float(val)<br />
  except ValueError, e:<br />
    return False<br />
  return True</p>
<p>&#8220;.-02&#8243; FALSE<br />
&#8220;-.02&#8243; TRUE<br />
&#8220;.02.&#8221; FALSE<br />
&#8220;02.-&#8221; FALSE<br />
&#8220;0.00&#8243; True<br />
&#8220;-1.2&#8243; TRUE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-409</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sat, 17 Apr 2010 03:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-409</guid>
		<description>That&#039;s true. Good point. However, I have never come across such values in practice. I think the point of all of this is that you have to evaluate your needs for a given task, and sometimes a simple but unconventional approach can do the trick. Sometimes we may want to sacrifice accuracy for speed. And vice versa.</description>
		<content:encoded><![CDATA[<p>That&#8217;s true. Good point. However, I have never come across such values in practice. I think the point of all of this is that you have to evaluate your needs for a given task, and sometimes a simple but unconventional approach can do the trick. Sometimes we may want to sacrifice accuracy for speed. And vice versa.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anvesh</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-408</link>
		<dc:creator>anvesh</dc:creator>
		<pubDate>Fri, 16 Apr 2010 23:48:15 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-408</guid>
		<description>I would consider this case as not working. This is a false positive. The test passes even though it shouldn&#039;t.

isnumeric(&quot;.-2&quot;) // True

similarly

&quot;2.22.2-&quot;</description>
		<content:encoded><![CDATA[<p>I would consider this case as not working. This is a false positive. The test passes even though it shouldn&#8217;t.</p>
<p>isnumeric(&#8220;.-2&#8243;) // True</p>
<p>similarly</p>
<p>&#8220;2.22.2-&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-407</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 16 Apr 2010 23:43:51 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-407</guid>
		<description>Anvesh, in the post I mention it may not work for all cases. But I don&#039;t know of any cases where it wouldn&#039;t work. Do you? If so, I could tweak the code to handle those possibly.</description>
		<content:encoded><![CDATA[<p>Anvesh, in the post I mention it may not work for all cases. But I don&#8217;t know of any cases where it wouldn&#8217;t work. Do you? If so, I could tweak the code to handle those possibly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anvesh</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-406</link>
		<dc:creator>anvesh</dc:creator>
		<pubDate>Fri, 16 Apr 2010 20:06:05 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-406</guid>
		<description>whatever works for you, I prefer the one that is correct all the time and not just in most cases. 

And what do you mean by &quot;extremely slow&quot;? is it taking a min or an hour? I doubt that, the time difference is almost unnoticeable unless you are doing thousands of checks.</description>
		<content:encoded><![CDATA[<p>whatever works for you, I prefer the one that is correct all the time and not just in most cases. </p>
<p>And what do you mean by &#8220;extremely slow&#8221;? is it taking a min or an hour? I doubt that, the time difference is almost unnoticeable unless you are doing thousands of checks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xavisimsa</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-404</link>
		<dc:creator>xavisimsa</dc:creator>
		<pubDate>Fri, 16 Apr 2010 15:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-404</guid>
		<description>def isnumeric(value):
try:
int(value)
return True
except:
return False

it works perfect, but there is a big problem...it is extremely slow...

the first option is really fast</description>
		<content:encoded><![CDATA[<p>def isnumeric(value):<br />
try:<br />
int(value)<br />
return True<br />
except:<br />
return False</p>
<p>it works perfect, but there is a big problem&#8230;it is extremely slow&#8230;</p>
<p>the first option is really fast</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anvesh</title>
		<link>http://code.hammerpig.com/determine-whether-a-string-value-is-numeric-in-python.html/comment-page-1#comment-393</link>
		<dc:creator>anvesh</dc:creator>
		<pubDate>Mon, 05 Apr 2010 09:41:05 +0000</pubDate>
		<guid isPermaLink="false">http://codecomments.wordpress.com/?p=33#comment-393</guid>
		<description>def isnumeric(value):
	try:
		int(value)
		return True
	except:
		return False</description>
		<content:encoded><![CDATA[<p>def isnumeric(value):<br />
	try:<br />
		int(value)<br />
		return True<br />
	except:<br />
		return False</p>
]]></content:encoded>
	</item>
</channel>
</rss>

