Why is my python function not defined, when it exists in the same file?

若如初见. 提交于 2019-11-29 14:25:56

You haven't shown the actual code so it's hard to be sure, but I bet myFunction is defined after MyClass. The default value expression is evaluated when the __init__ method is defined, so myFunction must be defined at that point. Defining it later is too late.

myFunction is a variable, not a value so you can't use it as a default parameter.

Maybe you could use a lambda function as the default parameter instead of the name of a declared function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!