Skip to content

diazona/localscope

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

This package enables a sort of local variable scoping in Python. It provides a context manager that resets the definitions (and existence) of local variables on exit to what they were at the start of the with statement.

a = 3
with scope():
    a, b = 5, 7
# a is back to 3, b doesn't exist

There are also usage patterns that allow you to reset only certain variables, or all except certain variables.

This is particularly useful for interactive work in e.g. iPython notebooks. For real code, it's better to use a function.

About

Simple local variable scoping for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages