Skip to main content

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:

  1. Removes the module (and all submodules) from sys.modules
  2. 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 .py files, rewriting deport X into valid Python before compilation
  • Excepthook: catches SyntaxError in the main script, preprocesses the source, and re-executes it
  • Custom codec: files with # coding: deport are 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


Download files

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

Source Distribution

deport-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

deport-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

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

Hashes for deport-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1b0e3c3f59313fa7caebf93c60050a0966b24da166007d7a1bc4b58476f5410
MD5 3a99f33161c4269b1517549510dbb070
BLAKE2b-256 0e2287048b1343baa2bcd8cfa21a92e961baa541c764f2338621e66751ef6764

See more details on using hashes here.

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

Hashes for deport-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b486fe824a5e93bccc01d9b7f6a09c6f55f69eae476a36c5461a02c0d1a71394
MD5 44c1c694acf5f4229cc88d57fcbaced4
BLAKE2b-256 a9ac6c1f2752c52dfd5a147d440388822c0d3962b0027963e134edd9eecc454f

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