Python - Using function in parent from child
Question: ~~I am trying to make a module that when imported can be used to easily define
commands for an interactive 'console'. However this requires me to be able to
run a function from the parent file, which when I do so I get this:`<function
Test at 0x027234B0>` instead of the function being run.

I am somewhat new to using classes and modules in python so I am not sure what
I am meant to be doing.

Here is the module for the Menu (Menu.py): (Not complete, just trying to get
this working) ~~

I have just an imbecile and forgot to put the thing in quotes

    
    
    class Menu:
        def __init__(self):
            self.temp=0
            self.menuobj = dict()
    
        def add(self, command, function):
            self.menuobj[command] = function
            print(command)
            return 0
    
        def debug(self):
            print(self.menuobj)
    
        def lookup(self, command):
            return self.menuobj[command]
    
        def mainloop(self):
            while 1:
                x = input("> ")
                try:
                    self.menuobj[x]()
    
                except KeyError:
                    print("Not Found")
    
    if __name__ == "__main__":
        print("This module is meant to be imported")
    

And the module that calls it:

    
    
    import Menu
    def Men():
        a = Menu.Menu()
        a.add("1",Test)
        a.mainloop()
    
    def Test():
        print(Test)
    
    Men()
    


Answer: The issue is in your `Test()` function, not that its not getting called -

    
    
    def Test():
        print(Test)
    

You are printing the reference to `Test` itself, hence it prints what you get
- `<function Test at 0x027234B0>` .

Example to show this -

    
    
    >>> def a():
    ...     print(a)
    ...
    >>> a()
    <function a at 0x0018B198>
    

You should print something meaningful.

