Question: python 3 def a static method called forget in the class in order to : forget (object): a static method that forgets the specified bidict

python 3

def a static method called forget in the class in order to :

forget (object): a static method that forgets the specified bidict object, so all_objects doesnt return it.

class bidict(dict): def __init__(self, inital=[], **kargs): self._rdict = defaultdict(set) if inital is not None: super().update(inital) if len(kargs): super().update(kargs) for k in super().keys(): self._rdict[kargs[k]] |= {k} 

def all_objects ():

x=[]

for obj in gc.get_objects():

if isinstance(obj, bidict):

x.append(obj)

return x

 def forget(obj): del obj

but del obj does not work when I call bidict.all_objects() it still print everything

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!