Re: Overriding methods in classes you don't control

2005-03-29 Thread Amaury Forgeot d'Arc
Alex VanderWoude a écrit : Here's the situation. I'm using wxPython, and I want to make an enhancement in the __init__ method of all the frame classes. The ideal place to do this is in wxFrame.__init__, since any change there will automatically be inherited by the other frame classes (for example,

Re: Overriding methods in classes you don't control

2005-03-29 Thread Amaury Forgeot d'Arc
Alex VanderWoude a écrit : Here's the situation. I'm using wxPython, and I want to make an enhancement in the __init__ method of all the frame classes. The ideal place to do this is in wxFrame.__init__, since any change there will automatically be inherited by the other frame classes (for example,

Re: Overriding methods in classes you don't control

2005-03-28 Thread Alex VanderWoude
"Jp Calderone" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 28 Mar 2005 03:57:16 GMT, Alex VanderWoude <[EMAIL PROTECTED]> wrote: > >Is there a way to override a method on a class whose source you cannot > > change in such a way that you can hook into that method's code? A

Re: Overriding methods in classes you don't control

2005-03-28 Thread runsun pan
good point, andy. -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding methods in classes you don't control

2005-03-28 Thread andybak
I've also come across several situations where modifying existing classes seems the simplest and most intuitive thing to do. Obviously it is fine for quick hacks but people tend to go 'whoo' and wave their fingers around when people suggest it as a general technique. Has anyone got any exper

Re: Overriding methods in classes you don't control

2005-03-28 Thread runsun pan
Some untested idea: 1. find what is the base class of wxPython 2. x= subclass from that base class 3. make wxPython.__base__ = x Don't know if this works, but this is what I would try if I were u ('cos its ease). -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding methods in classes you don't control

2005-03-27 Thread John Roth
Look up "Aspect Oriented Programming" and Python. You should find several packages that can do this, together with discussions of how to make cuts and all that fun stuff. The feeling of power is very heady - until you have to maintain the resulting mess. John Roth "Alex VanderWoude" <[EMAIL PROTEC

Re: Overriding methods in classes you don't control

2005-03-27 Thread Steven Bethard
Alex VanderWoude wrote: Basically I want to change wxFrame.__init__ so that it looks sort of like this: def __init__(self, *args, **kwargs): # Some enhancements here. # The original code of this method, including the call to its ancestor. # Some more enhancements here. A

Re: Overriding methods in classes you don't control

2005-03-27 Thread Jp Calderone
On Mon, 28 Mar 2005 03:57:16 GMT, Alex VanderWoude <[EMAIL PROTECTED]> wrote: >Is there a way to override a method on a class whose source you cannot > change in such a way that you can hook into that method's code? After doing > some research, it appears that one way to do such a thing is to crea

Overriding methods in classes you don't control

2005-03-27 Thread Alex VanderWoude
Is there a way to override a method on a class whose source you cannot change in such a way that you can hook into that method's code? After doing some research, it appears that one way to do such a thing is to create a new (non-class) method, and then assign the new method to the class in questio