How can one reliably determine if an object has a numpy type?
I realize that this question goes against the philosophy of duck typing, but idea is to make sure a fun
Use the builtin type function to get the type, then you can use the __module__ property to find out where it was defined:
type
__module__
>>> import numpy as np a = np.array([1, 2, 3]) >>> type(a) >>> type(a).__module__ 'numpy' >>> type(a).__module__ == np.__name__ True