How do you call a function in a function?

后端 未结 4 1557
耶瑟儿~
耶瑟儿~ 2020-12-18 06:56

I have a function and I\'m making another one in which I need to call the first function. I don\'t have experience in Python, but I know that in languages like MATLAB it\'s

4条回答
  •  醉梦人生
    2020-12-18 07:09

    If, and only if, you have the square function defined in a square module, then you should look to import the simple name from it instead.

    from square import square
    

    If you don't want to change anything, then you need to use its fully qualified name:

    something = square.square(y) + square.square(z)
    

    The module's name is square, and you can't call functions on modules.

提交回复
热议问题