What's better about Ruby than Python?

Alexander Schmolck a.schmolck at gmx.net
Mon Aug 18 20:46:20 EDT 2003


Gonçalo Rodrigues <op73418 at mail.telepac.pt> writes:

> On 18 Aug 2003 23:40:58 +0100, Alexander Schmolck <a.schmolck at gmx.net>
> wrote:

> >But of course what currently happens is:
> >
> >'just a method'
> >
> 
> And rightly so,  you have just rebinded a name. If you type
> 
> x.__class__
> 
> you get the older X. Or are you proposing that rebinding X to
> automagically rebind the __class__ of all the X instances?

Well, yes, I propose that x.__class__ return the *new* definition of X (like
in ruby, for example). I don't think that necessarily involves rebinding
anything "automagical", depending on how the lookup of x.__class__ works.

Can you give my any reason why you would *not* want all instances to be
updated on class redefinition?


> 
> But why can't you just
> 
> X.amethod = lambda self: "ah, now THIS is better!"
> 
> that is, mutate the class referenced by X instead of rebinding X to
> some other class?

Um, didn't you read what I wrote or was I just unclear?

To recap: usually, if I change a class I'd like all pre-existing instances to
become updated (Let's say you develop your program with a running python
session; you notice a mistake in a method-definition but don't want to start
over from scratch; you just want to update the class definition and have this
update percolate to all the currently existing instances. This is an *very*
reasonable wish if it doesn't just take seconds to get to the current state by
rerunning everything, but possibly hours or days). AFAIK doing this in a
general and painfree fashion is pretty much impossible in python (you have to
first track down all instances -- not an easy task, as far as I can see and
then updating their .__class__ might not quite work as expected either as I've
already mentioned).

I think this sucks big time, because it greatly devalues the interactive
programming experience for certain tasks, IMHO, but maybe I'm just missing
something since typically nobody complains.

'as




More information about the Python-list mailing list