def mod_exists(mod):
    if (not hasattr(mod, '__file__')):
        return False
    if (mod.__file__ is None):
        return False
    filename = mod.__file__
    (base, ext) = splitext(filename)
    ext = ext.lower()
    from os.path import exists
    if (ext == '.pyc'):
        return exists((base + '.py'))
    else:
        return (ext == '.py')
def mod_exists(mod):
    if (not hasattr(mod, '__file__')):
        return False
    if (mod.__file__ is None):
        return False
    filename = mod.__file__
    (base, ext) = splitext(filename)
    ext = ext.lower()
    from os.path import exists
    if (ext == '.pyc'):
        return exists((base + '.py'))
    else:
        return (ext == '.py')