A custom importer package
Project description
My Import Package
This package provides custom import functionalities.
Installation
pip install my-unique-import
Usage
This package can help with custom module imports, including importing specific functions from modules, getting the location of a module, and setting up paths for module discovery.
Setting up paths
The setup_paths module allows you to add the project root directory to the Python path dynamically.
from my_import.setup_paths import setup_paths
# Call this function at the beginning of your script
setup_paths()
Custom importer
The custom_importer module provides various utilities for importing modules and functions dynamically.
Import a specific function from a module
from my_import.custom_importer import import_from
# Import the 'sqrt' function from the 'math' module
sqrt = import_from('math', 'sqrt')
print(sqrt(16)) # Output: 4.0
Import a module
from my_import.custom_importer import import_module
# Import the 'os' module
os_module = import_module('os')
print(os_module.name) # Output: posix (or 'nt' on Windows)
Get the location of a module
from my_import.custom_importer import get_location
# Get the location of the 'math' module
location = get_location('math')
print(location) # Output: The file path to the 'math' module
Functions setup_paths This function adds the project root directory to the Python path dynamically, allowing you to import modules from the project more easily.
import_from This function allows you to import a specific function from a given module.
Parameters:
module (str): The name of the module. function (str): The name of the function to import. Returns:
The imported function. import_module This function imports a module dynamically.
Parameters:
name (str): The name of the module to import. package (str, optional): The package name to use for relative imports. Returns:
The imported module. get_location This function returns the file path to the specified module.
Parameters:
module (str): The name of the module. Returns:
The file path of the module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file my_unique_import-0.3.17.tar.gz.
File metadata
- Download URL: my_unique_import-0.3.17.tar.gz
- Upload date:
- Size: 69.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e159bc628f83adea30ae6835fa90a9cd7e42ad884196c7d7f4e02b0b9ce12338
|
|
| MD5 |
dd4cadbf96d7021d9b1ad6827b5ac4d9
|
|
| BLAKE2b-256 |
ccfed2fddee42aee9461c6eb62c25fd6ed441b6bb518d256bdc8a217417582cf
|
File details
Details for the file my_unique_import-0.3.17-py3-none-any.whl.
File metadata
- Download URL: my_unique_import-0.3.17-py3-none-any.whl
- Upload date:
- Size: 98.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1f37926b47e53ec8b77086213710a953285e36f5402b6659eb74051f526cf42
|
|
| MD5 |
87278b8b07a27b09e92ca06ce36f120b
|
|
| BLAKE2b-256 |
f5548a744db44a1a7ff1cd35d2ab17577858d700dacde1633d6ab11ad08dae0f
|