# deport

The opposite of `import`.

```
pip install deport
```

## Usage

```python
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

```python
deport os           # single module
deport os, json     # multiple modules
deport os.path      # submodule (also removes os from scope)
```

## Why

Why not?
