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

Method drop_by_id

IPython/core/interactiveshell.py:1638–1654  ·  view source on GitHub ↗

Remove a dict of variables from the user namespace, if they are the same as the values in the dictionary. This is intended for use by extensions: variables that they've added can be taken back out if they are unloaded, without removing any that the user has overwritt

(self, variables)

Source from the content-addressed store, hash-verified

1636 user_ns_hidden.update(vdict)
1637
1638 def drop_by_id(self, variables):
1639 """Remove a dict of variables from the user namespace, if they are the
1640 same as the values in the dictionary.
1641
1642 This is intended for use by extensions: variables that they've added can
1643 be taken back out if they are unloaded, without removing any that the
1644 user has overwritten.
1645
1646 Parameters
1647 ----------
1648 variables : dict
1649 A dictionary mapping object names (as strings) to the objects.
1650 """
1651 for name, obj in variables.items():
1652 if name in self.user_ns and self.user_ns[name] is obj:
1653 del self.user_ns[name]
1654 self.user_ns_hidden.pop(name, None)
1655
1656 #-------------------------------------------------------------------------
1657 # Things related to object introspection

Callers 2

test_drop_by_idMethod · 0.80
unload_ipython_extensionFunction · 0.80

Calls 1

popMethod · 0.80

Tested by 1

test_drop_by_idMethod · 0.64