Metadata-Version: 2.1
Name: scope-cleaner
Version: 0.1.0.post3
Summary: An IPython cell magic to remove temporary variables
License: MIT
Author: Nikolay Chechulin
Author-email: nchechulin@protonmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: ipython (>=8.5.0,<9.0.0)
Project-URL: Bug tracker, https://github.com/NChechulin/scope-cleaner/issues
Project-URL: Homepage, https://github.com/NChechulin/scope-cleaner
Description-Content-Type: text/markdown

# Scope cleaner

An IPython cell magic to remove temporary variables.
I wrote this package because I didn't like by global scope to be cluttered with variables I used in 1 cell only during EDA (Exploratory Data Analysis).

## Installation

[![PyPi version](https://badgen.net/pypi/v/scope-cleaner/)](https://pypi.org/project/scope-cleaner)

Via pip: `pip install scope-cleaner`

## Usage

Firstly, one needs to import the package: `import scope_cleaner`.
Then a new magic becomes available: `%%cleanup_temporary_vars <optional_prefix>`.
Optional prefix is a parameter which helps to filter out the temporary variables introduced in current cell.
If it's not set, the prefix defaults to `_`.

Example:
Consider the following IPython cells:

**Cell 2**
```python
%%cleanup_temporary_vars tmp

a = 10
b = 15

tmp_1 = 123
tmp_2 = 234

print("tmp", tmp_1, tmp_2)  # Out: tmp 123 234
tmp_1 + tmp_2  # Out: 357
```

So all the variables from current cell work correctly.

**Cell 3**
```python
a + b  # Out: 25
tmp_1  # Error: no such variable
```

As we can see, the temporary variable was automatically deleted by `%%cleanup_temporary_vars` in the end of previous cell (because its name starts with `tmp`).


