def some_func():
    return 'just a test'

def test(var):
    try:
        return var.__name__
    except AttributeError:
        # not something named (function, class, module)
        return None

print('%r' % test(some_func))
some_func2 = some_func
print('%r' % test(some_func2))
