×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to return function from another function

Here, we will write a Python program with a function that returns another function. By Shivang Yadav Last updated : January 05, 2024

Python allows programmers to return a function from another function like it allows function as an argument.

This is possible because python treats its functions as class objects.

Program to return a function from another function

# function - foo()
def foo():
    print("I am Foo")

# function - koo() returning foo
def koo():
    return foo

# calling the koo()
x=koo()
# calling function returned by koo()
x()

Output

The output of the above example is:

I am Foo

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.