An IPython cell magic to remove temporary variables
Project description
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
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
).
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
Hashes for scope_cleaner-0.1.0.post4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e57f06024e092ec1046283e1397f4b1f0f71bbf5245704a6a812a0d6ae764fc |
|
MD5 | dc0c183ec0bc32c5a5f727a365cbec84 |
|
BLAKE2b-256 | 40a281a7a5f2829bbebf9aa81ab562ab676aec2711f49d26665003e22b31c3db |
Hashes for scope_cleaner-0.1.0.post4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba8c14d7cb465dab78dcab83e266968d404c0b27aac9fd471ef8c0058e6bd7c5 |
|
MD5 | 07570e95210ccc200f2d72d32a58f540 |
|
BLAKE2b-256 | dfaa56c0b688bdcbcb29e8253ea84f945f7ae705697dce706584bba4900de1eb |