Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset_selective does not clear _n variables #12679

Open
flying-sheep opened this issue Oct 27, 2020 · 1 comment
Open

reset_selective does not clear _n variables #12679

flying-sheep opened this issue Oct 27, 2020 · 1 comment

Comments

@flying-sheep
Copy link
Contributor

In[1]: %reset_selective -f ^_[_\d]*$
       assert '_5' not in globals()
––––––––––––––––––––––––––––––––––––
       AssertionError:
@flying-sheep
Copy link
Contributor Author

Workaround:

def clean():
    from IPython import get_ipython
    ip = get_ipython()
    for k in list(ip.user_ns.keys() | ip.user_ns_hidden.keys()):
        if k[0] == '_' and len(k) == 1 or k[1] in '_0123456789':
            if k in ip.user_ns: del ip.user_ns[k]
            if k in ip.user_ns_hidden: del ip.user_ns_hidden[k]
    ip.user_ns_hidden['Out'].clear()
    ip.user_ns_hidden['_oh'].clear()
    gc.collect()

clean()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant