{"id":15628990,"url":"https://github.com/pwwang/python-import-system","last_synced_at":"2025-04-29T09:56:16.672Z","repository":{"id":49747328,"uuid":"320704253","full_name":"pwwang/python-import-system","owner":"pwwang","description":"Python import system diagram","archived":false,"fork":false,"pushed_at":"2020-12-12T00:24:21.000Z","size":17,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-29T09:56:10.760Z","etag":null,"topics":["diagram","python","python-imports"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-11T23:10:48.000Z","updated_at":"2024-05-14T05:40:28.000Z","dependencies_parsed_at":"2022-09-24T04:43:07.456Z","dependency_job_id":null,"html_url":"https://github.com/pwwang/python-import-system","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpython-import-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpython-import-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpython-import-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpython-import-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwwang","download_url":"https://codeload.github.com/pwwang/python-import-system/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251480069,"owners_count":21596016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagram","python","python-imports"],"created_at":"2024-10-03T10:25:14.742Z","updated_at":"2025-04-29T09:56:16.656Z","avatar_url":"https://github.com/pwwang.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Python Import System](./Python_Import_System.svg)\n\nDiagram is drawn based on python's [office documentation][1]\n\n## Pseudo code\n\n```python\n# import name, __import__(name), importlib.import_module(name), etc\n\nif name in sys.modules:\n    if sys.modules[name] is None:\n        raise ModuleNotFoundError\n    else if \"from import statement\":\n        locals()[name] = module\n    else:\n        return module\nelse:\n    for finder in sys.meta_path:\n        spec = finder.find_spec(name, ...)\n        if spec is not None:\n            if spec.loader is None:\n                raise ImportError\n            else:\n                module = spec.loader.create_module(spec)\n                spec.loader.exec_module(module)\n                if \"from import statement\":\n                    locals()[name] = module\n                else:\n                    return module\n        else:\n            continue\n    else:\n        raise ModuleNotFoundError\n```\n\n## Experiments\n\nSee [playground.ipynb](./playground.ipynb) for some experiments on the diagram.\n\n[1]: https://docs.python.org/3/reference/import.html\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fpython-import-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwwang%2Fpython-import-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fpython-import-system/lists"}