Two functions are provided which allow an application to determine if
an AST was create as an expression or a suite. Neither of these
functions can be used to determine if an AST was created from source
code via expr()
or suite()
or from a parse tree via
sequence2ast()
.
ast
represents an 'eval'
form, this function
returns a true value (1
), otherwise it returns false
(0
). This is useful, since code objects normally cannot be
queried for this information using existing built-in functions. Note
that the code objects created by compileast()
cannot be queried
like this either, and are identical to those created by the built-in
compile()
function.
isexpr()
in that it reports whether an
AST object represents an 'exec'
form, commonly known as a
``suite.'' It is not safe to assume that this function is equivelent
to not isexpr(ast)
, as additional syntactic fragments may
be supported in the future.