plugin interface / list

Larry Bates larry.bates at websafe.com
Wed Nov 9 01:57:08 CET 2005


webograph wrote:
> hi,
> i'm about to write a script to play various audio files. what i want to
> write is a directory (module) containing wrappers around various players
> that supply a player object (inheriting from a general player object
> defined earlier) and an entry in a list of mime types (which player is
> for which type).
> i've tried various forms of import and __init__.py configurations, but i
> repeatedly have problems with the following steps:
> - create an object inheriting from the main script
> - fill the dictionary declared there
> (i guess the problem is actually the same)
> 
> is there a standard way of doing such things?
> 
> thanks in advance
> webograph

Assuming that I understand your problem. One way is
(not tested):

class audioBase:
    def __init__(self, **kwargs):
        self.__dict__.extend(**kwargs)
        return

    #
    # Define base methods
    #

class mp3player(audioBase):
    def __init__(self, **kwargs):
        audioBase.__init__(self, **kwargs)
        return

    #
    # Define mp3player specific methods


#
# Main program
#

obj=mp3Player(file='abc.mp3', <add other keyword arguments>)

-Larry Bates



More information about the Python-list mailing list