I found a piece of art in a code today. So I'm sharing it to you.
The guy was trying to check if a variable 'member' is a class from the module 'mod'
He figured that str(member) would return it's class representation, something like that:
>>> str(member)
<class 'polygon.rectangle.square.SimpleSquare'>
He also figured that the object 'mod' had a 'name' attribute:
>>> mod.__file__
'polygon.rectangle.square'
So, to check if the object 'member' is a class from the module 'mod' he did:
>>> if str(member).find(mod.__name__) > 0:
...
If you want to check if a class is from a givem module, you can use the 'inspect' package:
>>> import inspect
>>> inspect.getmodule(member) is mod
True