Import Python objects from arbitrary locations
Project description
importloc
Import Python objects from arbitrary locations
Features
- Import module from file
path/to/file.py - Import object from file
path/to/file.py:object[.attr...] - Import object from module
[...package.]module:object[.attr...] - No dependencies
- 100% test coverage (to be implemented)
- Detailed documentation
Installation
$ pip install importloc
Usage
module_from_file
>>> from importloc import *
>>> foobar = module_from_file('example/foobar.py')
>>> foobar
<module 'foobar' from '/.../example/foobar.py'>
object_from_file
>>> from importloc import *
>>> baz = object_from_file('example/foobar.py:baz')
>>> baz
<function baz at 0x...>
object_from_module
>>> from importloc import *
>>> baz = object_from_module('example.foobar:baz')
>>> baz
<function baz at 0x...>
Changelog
All notable changes to this project will be documented in this file. Changes for the upcoming release can be found in News directory.
- The format is based on Keep a Changelog
- This project adheres to Semantic Versioning
v0.1.1 — 2025-01-17
Changed:
- When importing module from file, path is resolved to absolute (#7)
Docs:
- Published documentation on importloc.readthedocs.io (#4)
- Added
sphinx.ext.viewcodeplugin to view source code (#10) - Added changelog to readme (#12)
- Added
sphinx-sitemapplugin for website sitemap (#14) - Added API version history directives (#15)
v0.1.0 — 2025-01-15
Added 🌿
- Initial release (#1)
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
importloc-0.1.1.tar.gz
(74.1 kB
view details)
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 importloc-0.1.1.tar.gz.
File metadata
- Download URL: importloc-0.1.1.tar.gz
- Upload date:
- Size: 74.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
215c428fe05801a6e88bd88ffadd77457fcdad896489aef1db909e32fe7fb635
|
|
| MD5 |
28f304279808e9d7e45ec183de6de5e3
|
|
| BLAKE2b-256 |
373e7f54223a9382bfab300d912ac39429a966bf6e17376b2b9f8fc5c270cf44
|
File details
Details for the file importloc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: importloc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c364352d77df0819ff82cb01be606355c39ce2d4d5ba1e8d38e401ac73581010
|
|
| MD5 |
24cbc404c0b21cba895f01435480e21a
|
|
| BLAKE2b-256 |
a640933f938388b9ae18dd194664ae2ebb32ea4a282e6b63a633085050e17fc2
|