Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Advanced Objects Subclassing Built-ins

Error In code List

import copy


class FilledList(list):
    def __init__(self, count, value, *args, **kwargs):
        super.__init__()
        for _ in range(count):
            self.append(copy.copy(value))


fl = FilledList(9, 2)
print(len(fl))
Traceback (most recent call last):
  File "E:/python treehouse practice/oop/filledlist.py", line 11, in <module>
    fl = FilledList(9, 2)
  File "E:/python treehouse practice/oop/filledlist.py", line 6, in __init__
    super.__init__()
TypeError: descriptor '__init__' of 'super' object needs an argument

Why this error occur i m using pycharm

1 Answer

Steven Parker
Steven Parker
231,248 Points

It looks like you forgot the parentheses after "super":

        super.__init__()      # original
        super().__init__()    # fixed

Oh . Thanks i did not notice that little mistake