简体   繁体   中英

Error trying to inherit from pygame.midi

I am working on a program, and I want to have a class that inherits everything from pygame.midi. However, when I attempt to do this, I get this error:

Traceback (most recent call last):
  File "/Users/KelsenHazelwood/Documents/School/CS 23000/qBasicMusicMaker.py", line 5, in 
    class userSong (midi):
TypeError: module.__init__() takes at most 2 arguments (3 given)

Here is the code I've been working with:

from pygame import midi

class userSong (midi):
    def __init__ (self):
        pass
        #super (midi,self).__init__()

def main():
    k = userSong ()

main ()

pygame.midi is a module . You can't inherit from a module, only classes. You could import every class in pygame.midi , and inherit from one of them. Technically, it would be possible to inherit from all of them , but that's a terrible idea - the functionality is split into various classes for a reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM