Function annotation in python 3 get “name not defined” error

前端 未结 2 1337
长发绾君心
长发绾君心 2021-01-22 08:37

I am trying to use python3 type annotation features.

Here is some toy functions without annotation:

def fa(func, *args):
    return func(*args)
def fb(x:         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-22 09:19

    As the error message tells you, the name function isn't defined. If you want to hint as a function, put it in quotes:

    def fa(func: 'function', *args):
    

提交回复
热议问题