Fw: Is there a reason not to do this?

2006-12-02 Thread Hendrik van Rooyen
Hendrik van Rooyen [EMAIL PROTECTED] wrote: Ron Garret [EMAIL PROTECTED] wrote: I don't want to get into a philosophical debate. Actually, I changed my mind. Consider: so did I - I think the chair analogy is not quite clear, so let me elucidate: def g(): print 'G' def h():

Re: Is there a reason not to do this?

2006-12-02 Thread Michele Simionato
Since we are in a hackish mood, another alternative - interesting if you want the freedom to update your instances selectively - is to change their class at runtime. In this way you can specify which instances must use the new version of the class and which ones must keep the old one. It may be

Re: Is there a reason not to do this?

2006-12-02 Thread Michele Simionato
Ron Garret wrote: Doesn't work for me: c2 __main__.C2 instance at 0x51e850 c2.m1() G class C2: ... __metaclass__ = modify_in_place ... def m1(self): print 'Q' ... c2.m1() G C2().m1() Q I assume your original C2 class was defined in a different module, not in the current

Re: Is there a reason not to do this?

2006-12-01 Thread Michele Simionato
Ron Garret wrote: One of the things I find annoying about Python is that when you make a change to a method definition that change is not reflected in existing instances of a class (because you're really defining a new class when you reload a class definition, not actually redefining it). So

Re: Is there a reason not to do this?

2006-12-01 Thread Paul McGuire
Ron Garret [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] These objects can be parts of huge networks of massively linked data structures. They are in constant flux. It is not uncommon to hit a bug after many minutes, sometimes hours, of computation. Having to store the whole

Re: Is there a reason not to do this?

2006-12-01 Thread Carl Banks
Ron Garret wrote: In article [EMAIL PROTECTED], Ron Garret [EMAIL PROTECTED] wrote: I don't want to get into a philosophical debate. Actually, I changed my mind. Consider: def g(): print 'G' def h(): print 'H' def f(): g() class C1: def m1(self): f() class C2: def m1(self):

Re: Is there a reason not to do this?

2006-12-01 Thread Ron Garret
In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: The principle behind this is pretty much it was just a language design decision. Yes, and I'm not taking issue with the decision, just pointing out that the desire to do things differently is not necessarily perverse. P.S.

Re: Is there a reason not to do this?

2006-12-01 Thread Ron Garret
In article [EMAIL PROTECTED], Michele Simionato [EMAIL PROTECTED] wrote: Ron Garret wrote: One of the things I find annoying about Python is that when you make a change to a method definition that change is not reflected in existing instances of a class (because you're really defining a

Re: Is there a reason not to do this?

2006-12-01 Thread Hendrik van Rooyen
Ron Garret [EMAIL PROTECTED] wrote: I don't want to get into a philosophical debate. Actually, I changed my mind. Consider: def g(): print 'G' def h(): print 'H' def f(): g() class C1: def m1(self): f() class C2: def m1(self): g() c1 = C1() c2 = C2() def f(): h() class

Is there a reason not to do this?

2006-11-30 Thread Ron Garret
with this programming style: def defmethod(cls): return lambda (func): type.__setattr__(cls, func.func_name, func) class c1(object): pass @defmethod(c1) def m1(self, x): ... Now if you redefine m1, existing instances of c1 will see the change. My question is: is there a reason not to do this? Does

Re: Is there a reason not to do this?

2006-11-30 Thread Diez B. Roggisch
is: is there a reason not to do this? Does it screw something up behind the scenes? Is it unpythonic? Why isn't this standard operating procedure? What are you doing that needs this permanent redefinition? I like the repl, yet usually - especially when dealing with classes - I write a text file

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
): ... Now if you redefine m1, existing instances of c1 will see the change. My question is: is there a reason not to do this? Does it screw something up behind the scenes? Is it unpythonic? Why isn't this standard operating procedure? What are you doing that needs this permanent

Re: Is there a reason not to do this?

2006-11-30 Thread Carl Banks
) def m1(self, x): ... Now if you redefine m1, existing instances of c1 will see the change. My question is: is there a reason not to do this? Does it screw something up behind the scenes? Is it unpythonic? Why isn't this standard operating procedure? 1. Do you mean

Re: Is there a reason not to do this?

2006-11-30 Thread Paul McGuire
Carl Banks [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] A straightforward, Pythonic way to do it would be to create an intermediate representation that understands both the existing class interfaces and the RDB stuff, but that could lead to synchronizing problems and a big hit

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article [EMAIL PROTECTED], Hendrik van Rooyen [EMAIL PROTECTED] wrote: Ron Garret [EMAIL PROTECTED] wrote: One of the things I find annoying about Python is that when you make a change to a method definition that change is not reflected in existing instances of a class (because

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article [EMAIL PROTECTED], Ron Garret [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Hendrik van Rooyen [EMAIL PROTECTED] wrote: Ron Garret [EMAIL PROTECTED] wrote: One of the things I find annoying about Python is that when you make a change to a method

Re: Is there a reason not to do this?

2006-11-30 Thread Ron Garret
In article [EMAIL PROTECTED], Paul McGuire [EMAIL PROTECTED] wrote: Carl Banks [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] A straightforward, Pythonic way to do it would be to create an intermediate representation that understands both the existing class interfaces and