Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help ! -- AttributeError: type object 'super' has no attribute 'len'

Status
Not open for further replies.

dontknowwhy88

Technical User
Sep 8, 2007
1
0
0
I am new to Python.
I am writing a Stack class (extending list class) to perform push and pop.
However, when I try to call 'len' function from super class, I got an error msg --


AttributeError: type object 'super' has no attribute 'len'

Please help!!!
Thanks in advance!!

-here is my code -
------------------------
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'
'''
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top