Getting a class attribute

Alex alex at
Fri Mar 24 22:05:31 CET 2000

> That lets you get access to "self", but at the cost of rewriting the
> class method itself.

Ouch, yeah that could be bad.  It would be nice if you could make a new
version of the class, something like this:

new_class = copy.copy (self.__class__)
def new_degree_sin4 (self, deg, factor=(a*(math.pi/180)),
    return sin (deg * factor)
new_class.new_degree_sin4 = new_degree_sin4
self.__class__ = new_class

but it seems that classes aren't copy'able.  Plus, this has other
problems with class members that you actually would like to be
accessible to all instances.  Oh, well.


More information about the Python-list mailing list