On 13/08/21 11:42 am, Cameron Simpson wrote:
2: It took me a while to see, but this is a type annotiation.

Interestingly, it seems to be parsed as a form of assignment with
a missing RHS.

>>> from ast import parse, dump
>>> dump(parse("if0: print('yes!')"))
"Module(body=[AnnAssign(target=Name(id='if0', ctx=Store()), annotation=Call(func=Name(id='print', ctx=Load()), args=[Constant(value='yes!', kind=None)], keywords=[]), value=None, simple=1)], type_ignores=[])"

"An annotated assignment without the assignment? Eeuurgh!"

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to