plugin interface / list

W

webograph

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
 
L

Larry Bates

webograph said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,270
Messages
2,571,348
Members
48,033
Latest member
basiliskblack

Latest Threads

Top