MCPcopy Index your code
hub / github.com/ipython/ipython / reset_selective

Method reset_selective

IPython/core/interactiveshell.py:1568–1588  ·  view source on GitHub ↗

Clear selective variables from internal namespaces based on a specified regular expression. Parameters ---------- regex : string or compiled pattern, optional A regular expression pattern that will be used in searching variable names in the us

(self, regex=None)

Source from the content-addressed store, hash-verified

1566 setattr(self.displayhook, name, None)
1567
1568 def reset_selective(self, regex=None):
1569 """Clear selective variables from internal namespaces based on a
1570 specified regular expression.
1571
1572 Parameters
1573 ----------
1574 regex : string or compiled pattern, optional
1575 A regular expression pattern that will be used in searching
1576 variable names in the users namespaces.
1577 """
1578 if regex is not None:
1579 try:
1580 m = re.compile(regex)
1581 except TypeError as e:
1582 raise TypeError('regex must be a string or compiled pattern') from e
1583 # Search for keys in each namespace that match the given regex
1584 # If a match is found, delete the key/value pair.
1585 for ns in self.all_ns_refs:
1586 for var in ns:
1587 if m.search(var):
1588 del ns[var]
1589
1590 def push(self, variables, interactive=True):
1591 """Inject a group of variables into the IPython user namespace.

Callers

nothing calls this directly

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected