Python 如何在类中的函数中调用函数?

Python 如何在类中的函数中调用函数?,python,function,class,npyscreen,Python,Function,Class,Npyscreen,代码中有一个问题,类中的函数中有一个函数,我找不到运行第二个函数的方法 class startFunctionButton(npyscreen.ButtonPress): def whenPressed(self): IPScanForm.returnData ### Here should the function start class IPScanForm(npyscreen.NPSApp): ip="" def main(self

代码中有一个问题,类中的函数中有一个函数,我找不到运行第二个函数的方法

class startFunctionButton(npyscreen.ButtonPress):
    def whenPressed(self):
        IPScanForm.returnData ### Here should the function start

class IPScanForm(npyscreen.NPSApp):
        ip=""
        def main(self):
            f = npyscreen.FormWithMenus(name="Main Menu")
            IPselect = f.add(npyscreen.TitleText,name="IP Address: ")
            convertButtn = f.add(startFunctionButton,name="Start Function")

            def returnData(self): ### the second function
                IPScanForm.ip = IPselect.value ### thats just a placeholder could be anything

不能,此函数不需要在另一个函数中缩进。从何处运行第二个函数?在
main
内部,在定义之后,您可以像调用任何其他函数一样按名称调用它,但它不是一个实例方法,因此
self
参数不一定有意义。在
main
之外,除非显式返回该函数,否则该函数不可访问。现在还不清楚你到底想用它实现什么,所以很难看出最好的解决方案是什么。我出了问题,我怎么才能访问IPselect var?