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)
| 1509 | setattr(self.displayhook, name, None) |
| 1510 | |
| 1511 | def reset_selective(self, regex=None): |
| 1512 | """Clear selective variables from internal namespaces based on a |
| 1513 | specified regular expression. |
| 1514 | |
| 1515 | Parameters |
| 1516 | ---------- |
| 1517 | regex : string or compiled pattern, optional |
| 1518 | A regular expression pattern that will be used in searching |
| 1519 | variable names in the users namespaces. |
| 1520 | """ |
| 1521 | if regex is not None: |
| 1522 | try: |
| 1523 | m = re.compile(regex) |
| 1524 | except TypeError: |
| 1525 | raise TypeError('regex must be a string or compiled pattern') |
| 1526 | # Search for keys in each namespace that match the given regex |
| 1527 | # If a match is found, delete the key/value pair. |
| 1528 | for ns in self.all_ns_refs: |
| 1529 | for var in ns: |
| 1530 | if m.search(var): |
| 1531 | del ns[var] |
| 1532 | |
| 1533 | def push(self, variables, interactive=True): |
| 1534 | """Inject a group of variables into the IPython user namespace. |