The opposite of import
Project description
deport
The opposite of import.
pip install deport
Usage
import os
import json
deport os, json
# os and json are now completely unloaded from sys.modules and deleted from scope
import os # re-importing works — loads the module fresh
That's it. No special imports, no decorators, no configuration. Just pip install deport and the deport statement is available in all your Python files.
What it does
deport completely reverses an import:
- Removes the module (and all submodules) from
sys.modules - Deletes the name from the current scope
This means re-importing after a deport will reload the module from scratch, rather than returning the cached version.
How it works
When you pip install deport, a .pth file is installed into site-packages that activates the deport machinery at Python startup. It uses three mechanisms:
- Import hook: transparently preprocesses imported
.pyfiles, rewritingdeport Xinto valid Python before compilation - Excepthook: catches
SyntaxErrorin the main script, preprocesses the source, and re-executes it - Custom codec: files with
# coding: deportare preprocessed at decode time
Syntax
deport os # single module
deport os, json # multiple modules
deport os.path # submodule (also removes os from scope)
Why
Why not?
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 deport-0.1.0.tar.gz.
File metadata
- Download URL: deport-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1b0e3c3f59313fa7caebf93c60050a0966b24da166007d7a1bc4b58476f5410
|
|
| MD5 |
3a99f33161c4269b1517549510dbb070
|
|
| BLAKE2b-256 |
0e2287048b1343baa2bcd8cfa21a92e961baa541c764f2338621e66751ef6764
|
File details
Details for the file deport-0.1.0-py3-none-any.whl.
File metadata
- Download URL: deport-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b486fe824a5e93bccc01d9b7f6a09c6f55f69eae476a36c5461a02c0d1a71394
|
|
| MD5 |
44c1c694acf5f4229cc88d57fcbaced4
|
|
| BLAKE2b-256 |
a9ac6c1f2752c52dfd5a147d440388822c0d3962b0027963e134edd9eecc454f
|