On 07/02/12 19:32, Gregory, Matthew wrote:
class Statistics(object):
STAT = {
'MEAN': get_mean,
'SUM': get_sum,
}
...
if __name__ == '__main__':
spam = Statistics(4, 3)
print spam.get_stat('mean')
print spam.get_stat('sum')
Since a class is effectively a disguised dictionary I'm not sure why you
want to do this? If you just want to access the method by name then why
not just call getattr(spam,'get_mean')?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor