Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
215,396 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