Expressions can also be executed as statements, in which case they are
evaluated, but their value is discarded. Executing a pure function has no
effect, but executing a non-pure function can cause effects as a consequence of
function application.
If you want to change selection, open document below and click on "Move attachment"
1.5 Controlatement
describes some change to the interpreter state, and executing a statement
applies that change. As we have seen for return and assignment statements,
executing statements can involve evaluating subexpressions contained within
them.
<span>Expressions can also be executed as statements, in which case they are
evaluated, but their value is discarded. Executing a pure function has no
effect, but executing a non-pure function can cause effects as a consequence of
function application.
Consider, for instance,
>>> def square(x):
mul(x, x) # Watch out! This call doesn't return a value.
This example is valid Python, but probably not what was inte Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details