def is_proper_module(obj):
 return (inspect.ismodule(obj) and (obj is sys.modules.get(getattr(obj, '__name__', None))))

def is_proper_module ( obj ) : return ( inspect . ismodule ( obj ) and ( obj is sys . modules . get ( getattr ( obj , '__name__' , None ) ) ) )
returns true if obj can be treated like a garbage collector root .