From: Dossy Date: 2002-09-19T21:55:31+09:00 Subject: Re: Is better to subclass or to add methods to an existing class? On 2002.09.19, Vincent Foley wrote: > > 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: Um, what is Python doing with this block of code: def foo(): print "foo" ?? In Ruby, it simply adds a private method to the current object. So, if Python does the same (allowing you to add methods to instances of objects at runtime) then why would being able to add methods to a class of objects at runtime be the wrong thing? Granted I think in Ruby the inclination to add methods to existing base classes instead of subclassing them may be more common than it should be, but the feature is certainly one that makes Ruby very powerful when done right. -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)