gah! I hate the new string syntax

Alex Martelli aleaxit at yahoo.com
Fri Mar 16 08:43:27 EST 2001


"Pieter Nagel" <pieter at equinox.co.za> wrote in message
news:Pine.LNX.4.21.0103161350510.2809-100000 at bast.jhb.equinox.co.za...
> On Mon, 12 Mar 2001 17:56:33 +0100, Alex Martelli <aleaxit at yahoo.com>
wrote:
>
> > Focusing on the polymorphism needs, I see the issue in the mirror
> > way from you: it's a _weakness_ (of Python and most other languages)
> > that I can't add methods 'post-facto, from the outside' to existing
> > objects -- it impedes the most natural, elegant, typeswitch-free way
> > to add functionality.
>
> Not true. See my other message in this post for how to extend Python
> classes with new methods at runtime.

Ah, _classes_ (and, actually, also, if need be, _instances_), *NOT*
_all_ objects -- the type/class split again.  For example, you can't
add methods to 'all strings', as they belong to a type, not a class;
nor to compiled-regular-expressions, file-objects, complex-numbers,
dictionaries, tuples...


Alex






More information about the Python-list mailing list