What is the semantics of a Python 2.7 line containing ONLY identifier. I.e. simply
a
or
something
?
If you know the exact place in the Reference, I'd be very pleased. Tnx.
What is the semantics of a Python 2.7 line containing ONLY identifier. I.e. simply
a
or
something
?
If you know the exact place in the Reference, I'd be very pleased. Tnx.
An identifier by itself is a valid expression. An expression by itself on a line is a valid statement.
The full semantic chain is a little more involved. In order to have nice operator precedence, we classify things like "a and b" as technically both an
and_testand anor_test. As a result, a simple identifier technically qualifies as over a dozen grammar itemsa
stmtcan be composed of a singlesimple_stmt, which can be composed of a simglesmall_stmt, which can be composed of a singleexpr_stmt, and so on, down throughtestlist_star_expr,test,or_test,and_test,not_test,comparison,expr,xor_expr,and_expr,shift_expr,arith_expr,term,factor,power,atom, and finallyNAME.