Declare function at end of file in Python

前端 未结 5 1621
庸人自扰
庸人自扰 2020-11-27 15:23

Is it possible to call a function without first fully defining it? When attempting this I get the error: \"function_name is not defined\". I am coming from a C++ ba

5条回答
  •  日久生厌
    2020-11-27 15:42

    Python is a dynamic languuage and the interpreter always takes the state of the variables (functions,...) as they are at the moment of calling them. You could even redefine the functions in some if-blocks and call them each time differently. That's why you have to define them before calling them.

提交回复
热议问题