Get the latest tech news

Show HN: Localscope–Limit scope of Python functions for reproducible execution


šŸ” localscope# Have you ever hunted bugs caused by accidentally using a global variable in a function in a Jupyter notebook? Have you ever scratched your head because your code broke after restarting the Python kernel? localscope can help by restricting the variables a function can access. >>> from localscope import localscope >>> >>> a = 'hello world' >>> >>> @localscope ...

localscope.localscope( func:function|code| None=None,*, predicate: Callable| None=None, allowed: Iterable[ str]| str| None=None, allow_closure: bool=False) Restrict the scope of a callable to local variables to avoid unintentional information ingress. Interactive python sessions are outstanding tools for analysing data, generating visualisations, and training machine learning models. However, the interactive nature allows global variables to leak into the scope of functions accidentally, leading to unexpected behaviour.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Limit scope

Limit scope

Photo of Python functions

Python functions

Photo of Localscope

Localscope