1

i'm doing an UNO game using Pygame, i'm doing it with lists of cards and classes of each color, when I tried to test the inheritance for using the color class, I got this error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    x=example()
  File "C:/Users/Tamara/Desktop/TEC/UNO/UNOclases.py", line 93, in __init__
    Red.__init__(self,Redlist)
TypeError: unbound method __init__() must be called with Red instance as first argument (got example instance instead)

Here's the code (don't mind if one of the names is wrong written, I had to translate it from spanish):

class Red:

    def setSpecialRedCards(self):

        self.__Redlist.append(self.__steal2)
        self.__Redlist.append(self.__steal2)
        self.__Redlist.append(self.__Reverse)
        self.__Redlist.append(self.__Reverse)
        self.__Redlist.append(self.__Jump)
        self.__Redlist.append(self.__Jump)

    def setRedNumers (self, number,counter):
        while counter<=9:
            if numero!=0:
                self.__Redlist.append(number)
                self.__Redlist.append(number)
            else:
                self.__listaRoja.append(number)
            number+=1
            counter+=1

    def getRed(self):
        return self.__Redlist

    def __init__(self, Redlist=[]):
        self.__Redlist=Redlist
        self.__number0 = "red 0"
        self.__steal2 = "steal2"
        self.__Reverse = "Reverse"
        self.__jump = "jump"


class example:

    def __init__(self, Redlist=[]):
        Red.__init__(self,Redlist)

    def example2(self):
        return Red.__number0

Thank you for your help!

0

1 Answer 1

4

Your class example doesn't inherit from class Red.

Write

class example(Red):
    ....
Sign up to request clarification or add additional context in comments.

2 Comments

I had to edit the variable names that were in spanish, otherwise not a lot of people would've understood, and I would have gotten little to no response at all
If you do that, then produce a traceback with that edited code. Having tracebacks not matching the code is hard. And I don't think programmers are beyond abstracting simple classnames. I don't care if something is called Roja or Red.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.