Is this considered black magic?

Laura Creighton lac at strakt.com
Sun Nov 11 15:57:07 EST 2001


Okay, new version:

def foreach(object_list, method_name, *args):
    for object in object_list:
        try:
            method = getattr(object, method_name)
        except AttributeError:
            pass
        else:
            if callable(method):
                method(*args)

Did I miss something? 

Thanks to all who responded.

Laura Creighton




More information about the Python-list mailing list