But if you try to run this this through pybooard.py, then this no longer holds. Here is an example, called test.py:dhylands wrote: ↑Wed May 09, 2018 4:36 pmIn the REPL, each statement you execute is evaluated and if the return value from the statement is not equal to None, then the result is printed. Consider the following:An function which doesn't return anything winds up returning NoneCode: Select all
>>> def foo(): ... print('Hey there') ... return 42 ... >>> foo() Hey there 42 >>> def foo2(): ... print('Another print') ... return None ... >>> foo2() Another print >>> def foo3(): ... print('foo3') ... >>> foo3() foo3 >>> def foo4(): ... print('Before 3 * 3') ... 3 * 3 ... print('After 3 * 3') ... return 42 ... >>> foo4() Before 3 * 3 After 3 * 3 42
Code: Select all
def f():
print('in f()')
return 12
f()
def g():
return 13
g()
print('print g: ', g())
Code: Select all
python pyboard.py test.py
Code: Select all
$ python pyboard.py test.py
in f()
print g: 13