comments? storing a function in an object
ebonak at hotmail.com
Tue Jul 21 04:01:45 CEST 2009
Those were great suggestions!
Re 1: I used the __doc__ attribute to eliminate the parameter in the
constructor as you suggested. Also, much easier to specify the
character string with the actual function than later to match it
up like I was.
""" class to represent a function """
def __init__(self, fn, num_vars):
""" the function, its string representation, and the number of
self.fn = fn
self.fn_str = fn.__doc__
self.num_vars = num_vars
Re 2: I will need to read up on __call__ to see how to use it here ..
Re 3: I think I still need to have my own exception handler as I am
using the 'extended call syntax' now (I just learned about this
yesterday) and I will always just supply one argument, the
list. Or perhaps my custom exception will be superfluous once I
figure out __call__ ..?
Thank you for taking the time to help, always good to learn new things.
More information about the Python-list