[Python-Dev] FunctionDef.returns - explicit 'None' return type hint

Valentin Iovene valentin at too.gy
Thu Jan 19 16:34:35 EST 2017


> >>> t = compile('def f(): pass', '', 'exec', ast.PyCF_ONLY_AST)
> >>> print(t.body[0].returns)
> None
> >>> t = compile('def f() -> None: pass', '', 'exec', ast.PyCF_ONLY_AST)
> >>> print(t.body[0].returns)
> <_ast.NameConstant object at 0x10a900f28>
> >>>  print(t.body[0].returns.value)
> None

My bad, thank you my King. ;)

-- 
Valentin


More information about the Python-Dev mailing list