<br><div><span class="gmail_quote">On 10/27/07, <b class="gmail_sendername">Alan Gauld</b> &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>&quot;Dick Moores&quot; &lt;<a href="mailto:rdm@rcblue.com">rdm@rcblue.com</a>&gt; wrote<br><br>&gt; if type(n) == &#39;int&#39; or type(n) == &#39;long&#39;:<br>&gt;&nbsp;&nbsp; do something<br><br>don&#39;t use strings<br><br>
if type(n) == int<br><br>Or just use an instance of the same type:<br><br>if type(n) == type(42)<br><br>Alan G.<br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">
Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>or use types module&nbsp;<div><br class="webkit-block-placeholder"></div>
<div>import types</div><div><br class="webkit-block-placeholder"></div><div>if type(n) == types.IntType or type(n) == types.LongType :</div><div>&nbsp;&nbsp; &nbsp;blah!</div><div><br class="webkit-block-placeholder"></div><div>this comes handy especially for some unique conditions - like whether the function passed is a generator or a normal function (well I kinda had this problem ... :) )
</div><div><br class="webkit-block-placeholder"></div><div>ex.&nbsp;</div><div>if type(f) == types.GeneratorType or type(f) == types.lambdaType :<br clear="all">&nbsp;&nbsp; same blah!</div><div><br>-- <br>Aditya
</div>