From: timsuth@... (Tim Sutherland) Date: 2002-09-23T21:53:35+09:00 Subject: Re: Is better to subclass or to add methods to an existing class? In article , Vincent Foley wrote: >I was discussing with a (Python) friend last night. I told him that one >thing I liked better about Ruby than Python was that you could add >methods to already existing methods. [...] >But my friend told me that Python didn't have that because it was not a >good thing and it was not the proper way to do it. He said that the >true way of doing it, is to subclass (since Python 2.2 can now subclass >builtin types) the base class: [...] In Python 2.2 (I'm not sure how long Python has been able to do this) you can do class Foo: def hello(self, x): print "hello", x def goodbye(self, x): print "goodbye", x Foo.goodbye = goodbye f = Foo() f.goodbye("bob")