Skip to main content

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

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

%%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

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).

Release files for scope-cleaner 0.1.0.post4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scope-cleaner 0.1.0.post4
File Size Uploaded
scope_cleaner-0.1.0.post4.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scope-cleaner 0.1.0.post4
File Interpreter ABI Platform
scope_cleaner-0.1.0.post4-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / scope_cleaner-0.1.0.post4.tar.gz

Download URL scope_cleaner-0.1.0.post4.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0e57f06024e092ec1046283e1397f4b1f0f71bbf5245704a6a812a0d6ae764fc
BLAKE2b-256 checksum
How to use checksums
40a281a7a5f2829bbebf9aa81ab562ab676aec2711f49d26665003e22b31c3db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.19.13-arch1-1

Release files / scope_cleaner-0.1.0.post4-py3-none-any.whl

Download URL scope_cleaner-0.1.0.post4-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba8c14d7cb465dab78dcab83e266968d404c0b27aac9fd471ef8c0058e6bd7c5
BLAKE2b-256 checksum
How to use checksums
dfaa56c0b688bdcbcb29e8253ea84f945f7ae705697dce706584bba4900de1eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.19.13-arch1-1

Release history Release notifications | RSS feed

This release

0.1.0.post4 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page