Re: Is there an official way to add methods to an instance?

2008-04-08 Thread méchoui
On Apr 4, 5:25 pm, John Nagle [EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Paul Rubin a écrit : Brian Vanderburg II [EMAIL PROTECTED] writes: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. Ugh. Avoid that if

Re: Is there an official way to add methods to an instance?

2008-04-08 Thread [EMAIL PROTECTED]
On 8 avr, 11:39, méchoui [EMAIL PROTECTED] wrote: On Apr 4, 5:25 pm, John Nagle [EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Paul Rubin a écrit : Brian Vanderburg II [EMAIL PROTECTED] writes: I've checked out some ways to get this to work. I want to be able to add a new

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Peter Otten
Brian Vanderburg II wrote: I don't know if this is the correct place to send this question. It is. I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different methods that cause problems with

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Paul Rubin
Brian Vanderburg II [EMAIL PROTECTED] writes: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. Ugh. Avoid that if you can. But see: http://en.wikipedia.org/wiki/Monkey_patch --

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Bruno Desthuilliers
Paul Rubin a écrit : Brian Vanderburg II [EMAIL PROTECTED] writes: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. Ugh. Avoid that if you can. Why so ? OO is about objects, not classes, and adding methods on a

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Bruno Desthuilliers
Peter Otten a écrit : (snip) Anyway, here is one more option to add too the zoo: class A(object): ... def __init__(self, f, x): ... self._f = f ... self.x = x ... @property ... def f(self): ... return self._f.__get__(self) ... def __del__(self):

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread John Nagle
Bruno Desthuilliers wrote: Paul Rubin a écrit : Brian Vanderburg II [EMAIL PROTECTED] writes: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. Ugh. Avoid that if you can. Why so ? OO is about objects, not classes, and

Re: Is there an official way to add methods to an instance?

2008-04-04 Thread Charles Mason
And for such a behavior they've termed monkeying Thus, the coinage Monkeypatching for what you want to do: http://mail.python.org/pipermail/python-dev/2008-January/076194.html There are a group of people who think monkeypatching is destroying ruby. You still probably should avoid it for

Is there an official way to add methods to an instance?

2008-04-03 Thread Brian Vanderburg II
I don't know if this is the correct place to send this question. I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different methods that cause problems with 'deleting'/garbage collection (__del__ may never

Re: Is there an official way to add methods to an instance?

2008-04-03 Thread Roger Miller
On Apr 3, 2:57 pm, Brian Vanderburg II [EMAIL PROTECTED] wrote: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different methods that cause problems with 'deleting'/garbage collection (__del__ may never

Re: Is there an official way to add methods to an instance?

2008-04-03 Thread Gabriel Genellina
En Thu, 03 Apr 2008 21:57:56 -0300, Brian Vanderburg II [EMAIL PROTECTED] escribió: I don't know if this is the correct place to send this question. I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two

Re: Is there an official way to add methods to an instance?

2008-04-03 Thread Gabriel Genellina
En Thu, 03 Apr 2008 22:43:30 -0300, Roger Miller [EMAIL PROTECTED] escribió: On Apr 3, 2:57 pm, Brian Vanderburg II [EMAIL PROTECTED] wrote: I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different