MCPcopy Create free account
hub / github.com/ipython/ipython / drop_by_id

Method drop_by_id

IPython/core/interactiveshell.py:1581–1597  ·  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 o

(self, variables)

Source from the content-addressed store, hash-verified

1579 user_ns_hidden.update(vdict)
1580
1581 def drop_by_id(self, variables):
1582 """Remove a dict of variables from the user namespace, if they are the
1583 same as the values in the dictionary.
1584
1585 This is intended for use by extensions: variables that they've added can
1586 be taken back out if they are unloaded, without removing any that the
1587 user has overwritten.
1588
1589 Parameters
1590 ----------
1591 variables : dict
1592 A dictionary mapping object names (as strings) to the objects.
1593 """
1594 for name, obj in variables.items():
1595 if name in self.user_ns and self.user_ns[name] is obj:
1596 del self.user_ns[name]
1597 self.user_ns_hidden.pop(name, None)
1598
1599 #-------------------------------------------------------------------------
1600 # 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