<br><div><span class="gmail_quote">On 10/27/07, <b class="gmail_sendername">Alan Gauld</b> <<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>> wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>"Dick Moores" <<a href="mailto:rdm@rcblue.com">rdm@rcblue.com</a>> wrote<br><br>> if type(n) == 'int' or type(n) == 'long':<br>> do something<br><br>don'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 - <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 <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> 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. </div><div>if type(f) == types.GeneratorType or type(f) == types.lambdaType :<br clear="all"> same blah!</div><div><br>-- <br>Aditya
</div>