Function aliasing in Python Last Updated : 21 Mar, 2023 Comments Improve Suggest changes Like Article Like Report In Python, we can give another name of the function. For the existing function, we can give another name, which is nothing but function aliasing. Function aliasing in Python In function aliasing, we create a new variable and assign the function reference to one existing function to the variable. We can verify that both the objects pointing to the same memory location using id() built-in function in Python. Example 1: Basic usage of function aliasing in Python Python3 def fun(name): print(f"Hello {name}, welcome to GeeksForGeeks!!!") cheer = fun print(f'The id of fun() : {id(fun)}') print(f'The id of cheer() : {id(cheer)}') fun('Geeks') cheer('Geeks') Output: The id of fun() : 140716797521432 The id of cheer() : 140716797521432 Hello Geeks, welcome to GeeksForGeeks!!! Hello Geeks, welcome to GeeksForGeeks!!! Explanation: In the above example, only one function is available, but we can call that function by using either fun or cheer name. Example 2: Function aliasing of custom objects Here, we have defined a class Test and a method name() to return the u_name attribute of the class. Here, we are demonstrating the usage of function aliasing on the name() method of the test object. Python3 class Test: def __init__(self): self.u_name = "user-origin" def name(self): return self.u_name # create object of Test class test = Test() # create function reference and it's alias name_fn = test.name name_fn_ref = name_fn # this will print user-origin print(name_fn()) test.u_name = "user-mod" # this will print user-mod print(name_fn_ref()) Output: user-origin user-mod Explanation: name_fn is the function reference to the name() method of the test object. name_fn_ref is the function alias of the function name_fn. After changing the attribute value of u_name the function alias also reflects the change that establishes the fact that, name_fn and name_dn_ref points to the same function. Comment More infoAdvertise with us Next Article Function aliasing in Python arijitmondal2580 Follow Improve Article Tags : Python Practice Tags : python Similar Reads Currying Function in Python Currying is a functional programming technique where a function with multiple arguments is transformed into a sequence of functions, each taking a single argument.Mathematical IllustrationIn currying, a function that takes multiple inputs is broken down into a series of single-argument functions, ea 3 min read Function Annotations in Python Basic Terminology PEP: PEP stands for Python Enhancement Proposal. It is a design document that describes new features for Python or its processes or environment. It also provides information to the python community. PEP is a primary mechanism for proposing major new features, for example - Python W 7 min read First Class functions in Python First-class function is a concept where functions are treated as first-class citizens. By treating functions as first-class citizens, Python allows you to write more abstract, reusable, and modular code. This means that functions in such languages are treated like any other variable. They can be pas 2 min read Python int() Function The Python int() function converts a given object to an integer or converts a decimal (floating-point) number to its integer part by truncating the fractional part.Example:In this example, we passed a string as an argument to the int() function and printed it.Pythonage = "21" print("age =", int(age) 3 min read Python Built in Functions Python is the most popular programming language created by Guido van Rossum in 1991. It is used for system scripting, software development, and web development (server-side). Web applications can be developed on a server using Python. Workflows can be made with Python and other technologies. Databas 6 min read Function Composition in Python Function composition is a powerful concept where two or more functions are combined in such a way that the output of one function becomes the input for the next. It allows for the creation of complex functionality from simple, reusable building blocks. This concept is widely used in functional progr 6 min read Python 3 - input() function In Python, we use the input() function to take input from the user. Whatever you enter as input, the input function converts it into a string. If you enter an integer value still input() function converts it into a string.Python input() Function SyntaxSyntax: input(prompt)Parameter:Prompt: (optional 3 min read Python input() Function Python input() function is used to take user input. By default, it returns the user input in form of a string.input() Function Syntax: input(prompt)prompt [optional]: any string value to display as input messageEx: input("What is your name? ")Returns: Return a string value as input by the user.By de 4 min read Python len() Function The len() function in Python is used to get the number of items in an object. It is most commonly used with strings, lists, tuples, dictionaries and other iterable or container types. It returns an integer value representing the length or the number of elements. Example:Pythons = "GeeksforGeeks" # G 2 min read Assign Function to a Variable in Python In Python, functions are first-class objects, meaning they can be assigned to variables, passed as arguments and returned from other functions. Assigning a function to a variable enables function calls using the variable name, enhancing reusability.Example:Python# defining a function def a(): print( 3 min read Like