From: Jim Weirich Date: 2004-01-13T13:15:21+09:00 Subject: Re: faster integer arithmetics & arbitrary precision floating number gabriele renzi wrote: >>Python2.2's numbers are now also objects and thus it also has to check if it >>has to do the same type of dispatching that Ruby does, yet its speed is much, >>much closer to Perl's. > > still, you can't reopen base classes in python, IIRC.. You can't reopen them as you can in Ruby, but it is possible to add methods to a class after its definition. It involves assigning an unbounded method to a attribute. Warning ... Python code below :-) #===================================================== class X: def hi(self): print "Hello" print "-- First Time --------" x = X() x.hi() try: x.bye() except AttributeError: print "Got attribute error while calling bye" def adios(self): print "Bye" X.bye = adios print "-- Second Time ------" x.hi() x.bye() #====================================================== Output is .... ======================================================= -- First Time -------- Hello Got attribute error while calling bye -- Second Time ------ Hello Bye ======================================================= -- -- Jim Weirich jweirich@one.net http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)