I'm attending a python course in university, where we should implement a deque class as an assignment. Now I've got some problems with the output an instance should give given in the docstring.
class Deque:
"""
>>> d = Deque()
>>> d
Deque<>
>>> d = d.append(1); d
Deque<1>
>>> d.append(2).prepend(0) # allow for chaining of appending & prepending
Deque<0, 1, 2>
I have no idea how to achieve that an instance outputs this notation with the angle brackets.
Anybody got an idea?
Thanks in advance
You work can work that out in the
__repr__
of the class.As a simple example for an empty
Deque
instance:For a non-empty instance, you would simply format the returned string to include the contents of the instance.