[Tutor] Re: adding type methods?

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Oct 23 16:38:22 EDT 2003


> Now, this isn't what you asked, because the above example doesn't
add
> methods to and existing type, it creates a new type. (See the result
> of type(s).) I think adding to a built-in type isn't possible:

Not possible and potentially dangerous since you are changing
the behaviour of a standard type and some obscure bit of code
may depend on the methods that are there being fixed (because
it iterates over them doing something with the result say?)

Or some other module also adds a new method using the same
name and then you get all sorts of unexpected behaviours
occurring! And the fun of trying to work out which added
method gets called where!

One of the advantages of OOP is that you can add new behaviour
without changing the old behaviour.

Alan G.




More information about the Tutor mailing list