+ 1
Kindly explain this part!
THE PART WHICH I HAVE HIGHLIGHTED WITH ASTERISK...PLZ EXPLAIN THT class Queue: def __init__(self, contents): self._hiddenlist = list(contents) def push(self, value): self._hiddenlist.insert(0, value) def pop(self): return self._hiddenlist.pop(-1) ***** def __repr__(self): return "Queue({})".format(self._hiddenlist)*****
2 Respostas
+ 4
U need the __repr___ to print an instance of the class with a simple
print(instance)
+ 3
Yes. As said it's *Called automatically when an object is created so there in code it returning objects contents..
Check by this..
print(Queue("12345"))