Skip to main content

A utility for discovering and importing Python modules in a package or directory.

Project description

Usage

Importing all modules

You can import all modules under a given root directory, package, or module:

import mypackage  # your package or module
from pywalker import import_modules
import_modules(mypackage)

Filtering with patterns

You can filter which modules are imported using an fnmatch pattern (or list of patterns):

import mypackage
import_modules(mypackage, patterns='utils*')
import_modules(mypackage, patterns=['core*', 'utils*'])

Walking modules without importing

To just get the module names (without importing them):

import mypackage
from pywalker import walk_modules
for name in walk_modules(mypackage, patterns='*test*'):
    print(name)

Pattern argument

The patterns argument uses Unix shell-style wildcards (see Python's fnmatch):

  • * matches everything
  • ? matches any single character
  • [seq] matches any character in seq
  • [!seq] matches any character not in seq

Examples:

  • 'core*' matches modules starting with core
  • '*test*' matches modules containing test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unboil_pywalker-0.1.3.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unboil_pywalker-0.1.3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file unboil_pywalker-0.1.3.tar.gz.

File metadata

  • Download URL: unboil_pywalker-0.1.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unboil_pywalker-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7ebb5e7dbb5cfdf868aa32e5cbd46eaf615a731c763a4521f8b22d65aae192cf
MD5 f854346f6bfba648eb9dd87053133119
BLAKE2b-256 f8aee2fbb33e83a70f9f31b267f1dffa499025b10ea646d62ca29af925c86657

See more details on using hashes here.

File details

Details for the file unboil_pywalker-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for unboil_pywalker-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1062a65eaaab498af505989e381e084335b49b772e2b7af1a36a9c488c073d38
MD5 742b536f2dbb353993452c68caec1476
BLAKE2b-256 8ef86b336226a9783a33af5580ec144b2d04dd46df977d8fb21b740290ad173e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page