Skip to content

import pkgutil #74

@bendasgfyug

Description

@bendasgfyug

import pkgutil
import importlib

all = [] # Define all here

def _import_modules():
prefixLen = len(name) + 1
for _, moduleName, _ in pkgutil.iter_modules(path, prefix=f'{name}.'):
moduleNameWithoutPrefix = moduleName[prefixLen:]
all.append(moduleNameWithoutPrefix)
module = importlib.import_module(moduleName)

	globals()[moduleNameWithoutPrefix] = module

_import_modules()

Originally posted by @JeoCrypto in JustAnotherArchivist/snscrape#1036 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions