Python calling function in an function from another function

Mayers

I want to call 1 precise function in another function from another function

def exemple():    
    def dostuff1():  
        print('Stuff 1')  
    def dostuff2():  
        print('Stuff 2')  
    def dostuff3():  
        print('Stuff 3')  

def training():
    #want to call ONLY Dostuff2
gautamaggarwal

Define your function example as this:-

def exemple(func_name):    
    def dostuff1():  
        print('Stuff 1')  
    def dostuff2():  
        print('Stuff 2')  
    def dostuff3():  
        print('Stuff 3')
    func_dic = {
        "dostuff1" : dostuff1,
        "dostuff2" : dostuff2,
        "dostuff3" : dostuff3
    }
    return func_dic[func_name]

Then call your function in the other function like this:

def training():
    exemple("dostuff2")()

I hope it helps!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a Python function from another file

From Dev

Python - Calling a function from another class

From Dev

Python calling a function from another file

From Dev

Calling variable from another function in python

From Dev

Python - Calling a function from another class

From Dev

python - calling variable from another function

From Dev

Calling a variable from one function to another function in Python

From Dev

calling a function into another function

From Dev

Calling main function from another function in C

From Dev

Calling a function from inside another function?

From Dev

Calling variable from one function into another function

From Dev

Calling main function from another function in C

From Dev

Calling function with object parameter from another function

From Dev

Calling the BlogEntries function from another function [SilverStripe]

From Dev

Calling a class function from within another function

From Dev

Calling php function from inside another function

From Dev

Calling function from another activity

From Dev

Calling function from another component

From Dev

Calling a function from another package

From Dev

Calling a function from another Project

From Dev

flask calling a function from another

From Dev

Calling a function from another class?

From Dev

Calling a list in another function - Python

From Dev

Calling a function from within a function in Python

From Dev

Calling function in another class in another file in python

From Dev

Python: calling function inside a class inside a route from another file

From Dev

Calling a function from another file into another function C++

From Dev

Calling JS function in another function

From Dev

Calling C function from Python

Related Related

  1. 1

    Calling a Python function from another file

  2. 2

    Python - Calling a function from another class

  3. 3

    Python calling a function from another file

  4. 4

    Calling variable from another function in python

  5. 5

    Python - Calling a function from another class

  6. 6

    python - calling variable from another function

  7. 7

    Calling a variable from one function to another function in Python

  8. 8

    calling a function into another function

  9. 9

    Calling main function from another function in C

  10. 10

    Calling a function from inside another function?

  11. 11

    Calling variable from one function into another function

  12. 12

    Calling main function from another function in C

  13. 13

    Calling function with object parameter from another function

  14. 14

    Calling the BlogEntries function from another function [SilverStripe]

  15. 15

    Calling a class function from within another function

  16. 16

    Calling php function from inside another function

  17. 17

    Calling function from another activity

  18. 18

    Calling function from another component

  19. 19

    Calling a function from another package

  20. 20

    Calling a function from another Project

  21. 21

    flask calling a function from another

  22. 22

    Calling a function from another class?

  23. 23

    Calling a list in another function - Python

  24. 24

    Calling a function from within a function in Python

  25. 25

    Calling function in another class in another file in python

  26. 26

    Python: calling function inside a class inside a route from another file

  27. 27

    Calling a function from another file into another function C++

  28. 28

    Calling JS function in another function

  29. 29

    Calling C function from Python

HotTag

Archive