1

When I query isinstance() in the console it works True , but when I use it in a function it does not work False !?? Why does this happen ?

In [104]: type(ab)
Out[104]: isdp.iSDP

In [105]: isinstance(ab, iSDP)
Out[105]: True

In [106]: xbitx(ab)
type>  <class 'isdp.iSDP'> False

In [108]: xbitx??
Signature: xbitx(data)
Source:   
def xbitx(data): #extract bit indexes 
        print "type> ", type(data), isinstance(data, iSDP) 
        if isinstance(data, iSDP) : return data.bits
        return data
sten
  • 7,028
  • 9
  • 41
  • 63
  • 2
    I can't reproduce this. Where is your `xbitx()` function located? Does it import `iSDP` from a different module? – quamrana Mar 19 '20 at 17:01
  • yes ... i have 2 classes if it matters ... class iSDP(object): ... class isdp(object): ...with staticmethods – sten Mar 19 '20 at 17:13
  • 2
    Well, try renaming one, say `iSDP` to `iSDPX` (including the implementation of `xbitx()`) to see if the behaviour changes. – quamrana Mar 19 '20 at 17:25

0 Answers0