On Mon, Jan 19, 2009 at 1:36 PM, wesley chun <wes...@gmail.com> wrote: >> if type(x) == int: # check its an integer > > > i also understand that it's "isinstance(x, int)" should be used > instead of the above or "if type(x) is int" but i'm running a blank as > to why at this exact moment... perhaps it's an all-C function?
If x is an instance of a subclass of Y, 'type(x) == Y" and "type(x) is Y" will fail; isinstance(x, Y) will succeed. Generally it's preferable to allow subclasses so isinstance() is preferred. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor