On Aug 29, 3:03 pm, "Marshall T. Vandegrift" <[EMAIL PROTECTED]> wrote: > Marco Nawijn <[EMAIL PROTECTED]> writes: > > The problem I face is that the implementation of the application class > > is completely different for the local and remote case. The local case > > is a straightforward implemenation using the subprocess module, the > > remote case is a CORBA implementation. Somehow I would like to switch > > from implementation class at runtime depending on whether or not the > > host parameter is specified or not. > > > The Application, local implementation and remote implementation all > > have the same interface, so a possibility might be something like the > > following: > > <snipped example> > > > To me forwarding each call in the Application class looks a little bit > > redundant and I would like to get rid of it. Does anyone have any > > comments or suggestions? Can metaclass programming come to rescue? > > It sounds like you could probably get away with just a factory function: > > def Application(program, host=None): > if host is None: > return LocalApplication(program) > else: > return RemoteApplication(program, host) > > Then just implement the same interface and/or derive from a common base > class for LocalApplication and RemoteApplication. > > HTH!, > > -Marshall
Thanks! This makes perfect sense. (In these moments I always wonder why I didn't come up with this idea...) Thanks again. Regards, Marco -- http://mail.python.org/mailman/listinfo/python-list