Skip to content

diazona/localscope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

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