environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py
def del_var(self, varname, by_name=False):
        """Delete a variable from the various namespaces, so that, as
        far as possible, we're not keeping any hidden references to it.

        Parameters
        ----------
        varname : str
            The name of the variable to delete.
        by_name : bool
            If True, delete variables with the given name in each
            namespace. If False (default), find the variable in the user
            namespace, and delete references to it.
        """
        if varname in ('__builtin__', '__builtins__'):
            raise ValueError("Refusing to delete %s" % varname)

        ns_refs = self.all_ns_refs
        
        if by_name:                    # Delete by name
            for ns in ns_refs:
                try:
                    del ns[varname]
                except KeyError:
                    pass
        else:                         # Delete by object
            try:
                obj = self.user_ns[varname]
            except KeyError:
                raise NameError("name '%s' is not defined" % varname)
            # Also check in output history
            ns_refs.append(self.history_manager.output_hist)
            for ns in ns_refs:
                to_delete = [n for n, o in ns.iteritems() if o is obj]
                for name in to_delete:
                    del ns[name]

            # displayhook keeps extra references, but not in a dictionary
            for name in ('_', '__', '___'):
                if getattr(self.displayhook, name) is obj:
                    setattr(self.displayhook, name, None)
def del_var(self, varname, by_name=False):
        if varname in ('__builtin__', '__builtins__'):
            raise ValueError("Refusing to delete %s" % varname)

        ns_refs = self.all_ns_refs
        
        if by_name:                    # Delete by name
            for ns in ns_refs:
                try:
                    del ns[varname]
                except KeyError:
                    pass
        else:                         # Delete by object
            try:
                obj = self.user_ns[varname]
            except KeyError:
                raise NameError("name '%s' is not defined" % varname)
            # Also check in output history
            ns_refs.append(self.history_manager.output_hist)
            for ns in ns_refs:
                to_delete = [n for n, o in ns.iteritems() if o is obj]
                for name in to_delete:
                    del ns[name]

            # displayhook keeps extra references, but not in a dictionary
            for name in ('_', '__', '___'):
                if getattr(self.displayhook, name) is obj:
                    setattr(self.displayhook, name, None)
def del_var ( self , varname , by_name = False ) : if varname in ( '__builtin__' , '__builtins__' ) : raise ValueError ( "Refusing to delete %s" % varname ) ns_refs = self . all_ns_refs if by_name : # Delete by name for ns in ns_refs : try : del ns [ varname ] except KeyError : pass else : # Delete by object try : obj = self . user_ns [ varname ] except KeyError : raise NameError ( "name '%s' is not defined" % varname ) # Also check in output history ns_refs . append ( self . history_manager . output_hist ) for ns in ns_refs : to_delete = [ n for n , o in ns . iteritems ( ) if o is obj ] for name in to_delete : del ns [ name ] # displayhook keeps extra references, but not in a dictionary for name in ( '_' , '__' , '___' ) : if getattr ( self . displayhook , name ) is obj : setattr ( self . displayhook , name , None )
Delete a variable from the various namespaces, so that, as
        far as possible, we're not keeping any hidden references to it.

        Parameters
        ----------
        varname : str
            The name of the variable to delete.
        by_name : bool
            If True, delete variables with the given name in each
            namespace. If False (default), find the variable in the user
            namespace, and delete references to it.
Delete a variable from the various namespaces so that as far as possible we re not keeping any hidden references to it .