Add methods to a class at runtime?

Robert Oschler Oschler at earthlink.net
Sun Sep 1 19:13:53 EDT 2002


"Gerhard Häring" <gerhard.haering at gmx.de> wrote in message
news:mailman.1030916762.5578.python-list at python.org...
>
> I never saw such a note. Maybe you were reading a message from the
> (dormant) types-sig, where ways to introduce optional (!) stronger
> typing into Python are discussed. I never saw Guido make any comments
> about removing dynamic features from Python, though. With /one/
> exception, which you didn't mention, yet: assigning to the __class__
> attribute:
>

Yes it was in a thread where that was mentioned.  That's not a feature I
would miss, kind of scary (dynamically switching an instance's class).  The
add method stuff though is superb.  It's used to wonderful effect in XML
parsers I've seen for parsing.  If your're curious about the __dynamic__
keyword, here's the thread.  Look in the neighborhood of message #68 and
find the keyword __dynamic__ (wow what a great password this link would
make):

http://groups.google.com/groups?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8&safe=acti
ve&threadm=mailman.997727540.19628.python-list%40python.org&rnum=1&prev=/gro
ups%3Fhl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8%26safe%3Dactive%26q%3
DRe%253A%2BCopy%2Bconstructors%2Bpython

thx







More information about the Python-list mailing list