Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started