Python - Function name re-assignment

Introduction

You can reassign a function name.

othername = func           # Assign function object 
othername()                # Call func again 

Here, the function was assigned to a different name and called through the new name.

Python functions are objects; they are recorded explicitly in memory at program execution time.

Besides calls, functions allow arbitrary attributes to be attached to record information for later use:

def func(): ...            # Create function object 
func()                     # Call object 
func.attr = value          # Attach attributes 

Related Topic