<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 19, 2017 at 10:59 AM, Valentin Iovene via Python-Dev <span dir="ltr"><<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">With a ast.FunctionDef ast.AST node, is it possible to make the<br>
difference between this function<br>
<br>
def hello_world():<br>
print('hello world')<br>
<br>
and this one<br>
<br>
def hello_world() -> None:<br>
print('hello world')<br>
<br>
?<br>
<br>
In both cases, the FunctionDef node has its 'returns' (return type<br>
hint) attribute set to None.</blockquote><div><br>>>> t = compile('def f(): pass', '', 'exec', ast.PyCF_ONLY_AST)<br>>>> print(t.body[0].returns)<br>None<br>>>> t = compile('def f() -> None: pass', '', 'exec', ast.PyCF_ONLY_AST)<br>>>> print(t.body[0].returns)<br><_ast.NameConstant object at 0x10a900f28><br>>>> print(t.body[0].returns.value)<br>None<br>>>> <br></div></div><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/%7Eguido" target="_blank">python.org/~guido</a>)</div>
</div></div>