implementing add and iadd for custom class in python?
问题 I am writing a Queue class that wraps list for most of its operations. But I do not sublcass from list , since I do not want to provide all the list API's . I have my code pasted below. The add method seems to work fine, but iadd seems to go wrong, it is printing none. Here is the code: import copy from iterator import Iterator class Abstractstruc(object): def __init__(self): assert False def __str__(self): return "<%s: %s>" %(self.__class__.__name__,self.container) class Queue(Abstractstruc