def getname(f):
try:<EOL><INDENT>return f.__name__<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>return f.name<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>return str(f)<EOL>
Get the name of an object.

    For use in case of callables that are not functions, and
    thus may not have __name__ defined.

    Order: f.__name__ >  f.name > str(f)