How to store a function pointer in class?
Greg Ewing
greg at cosc.canterbury.ac.nz
Wed Jan 26 22:20:39 EST 2000
Sami Hangaslammi wrote:
>
> Yeah, I figured this out myself, but it still seems like an
> unneccessary and ugly hack.
It might be less ugly to use just one wrapper object for
all the functions in a given class, e.g.
class FunctionHolder:
pass
class MyClass:
functions = FunctionHolder()
MyClass.functions.f1 = some_function
MyClass.functions.f2 = another_function
MyClass.functions.f1(42)
etc.
--
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Python-list
mailing list