is this a bug?
Bjorn Pettersen
BPettersen at NAREX.com
Thu Aug 16 17:46:19 EDT 2001
> From: Vassilis Virvilis [mailto:vasvir at iit.demokritos.gr]
>
> Brian Quinlan wrote:
> >
>
> > The bottom line is that you should rarely use the "is"
> operator except
> > when testing if an object is None (there is only one None object in
> > Python).
> >
>
> Halo Brian,
>
> So is it safe to do?
> if type(a) is type(b): blah blah
In general, no -- although it will probably work most of the time in the
current implementation (didn't look too closely). The general idiom is:
import types
...
if type(x) == types.IntType:
...
although many people also use:
if type(x) == type(1):
-- bjorn
More information about the Python-list
mailing list