You do not need. Python evaluates everything at runtime:
def a():
print(b())
def b():
return 12
a()
therefore, when acalled b, it is already defined.
note: this does not work, because when a()called bis not yet defined:
def a():
print(b())
a()
def b():
return 12
Traceback (most recent call last):
File "<string>", line 420, in run_nodebug
File "<module1>", line 4, in <module>
File "<module1>", line 2, in a
NameError: name 'b' is not defined
source
share