Created
June 9, 2020 03:22
-
-
Save applenob/0fb2e5e7b5b2fcc0bd3e40190a609543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importlib | |
def find_name_path(root, name): | |
res = [] | |
try: | |
m = importlib.import_module(root) | |
except (AttributeError, ModuleNotFoundError) as e: | |
return res | |
if name in dir(m): | |
res.append(f"{root}.{name}") | |
for cand_root in dir(m): | |
cand_root = f"{root}.{cand_root}" | |
sub_res = find_name_path(cand_root, name) | |
if len(sub_res): res += sub_res | |
return res | |
print(find_name_path("tensorflow.compat.v1", "dynamic_rnn")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment