Scott David Daniels a écrit : > cantabile wrote: > >> bruno modulix a écrit : >> >>> You may want to have a look at the Factory pattern... >>> ... demo of class Factory ... > > > Taking advantage of Python's dynamic nature, you could simply: > # similarly outrageously oversimplified dummy example > class Gui(object): > def __init__(self, installer): > self.installer = installer > > class PosixGui(Gui): > pass > > class Win32Gui(Gui): > pass > > if os.name == 'posix': > makeGui = PosixGui > elif os.name == 'win32': > makeGui = Win32Gui > else: > raise "os %s not supported" % os.name > > > class Installer(object): > def __init__(self, guiFactory): > self.gui = guiFactory(self) > > def main(): > inst = Installer(makeGui) > return inst.gui.main() > > --Scott David Daniels > [EMAIL PROTECTED]
Thank you too for this tip. :) Coming from C++ (mainly), I'm not used to this dynamic way of doing things. That's usefull. -- http://mail.python.org/mailman/listinfo/python-list