×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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'
'''

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

Push and Pop ...
Lists do this already or am I missing something?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close