I am trying to extend list class to build a stack class -- see code below--- but I got an error when I try to call len method from list class here.. why? Thanks in advance! ---------------------
class Stackx(list): def push(self,x): indx= super.len(x) self.insert(my_len+1,x) def pop(self): return self[-1] def test(): myStack = Stackx([1, 2 ,3 ,4]) print myStack myStack.push(9) print myStack print myStack.pop() if __name__=='__main__': test() ''' Traceback (most recent call last): File "C:\Python25\Stack2.py", line 20, in <module> test() File "C:\Python25\Stack2.py", line 14, in test myStack.push(9) File "C:\Python25\Stack2.py", line 4, in push indx= super.len(x) AttributeError: type object 'super' has no attribute 'len' ''' --------------------------------- Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
-- http://mail.python.org/mailman/listinfo/python-list