3 ms·
What counts as a function definition? def a(): b() a() import random with open("max", "r") as f: m = int(f.read()) b = (lambda: "foo") if int(i
by chriswarbo 3y ago
What counts as a function definition?
def a(): b()
a()
import random
with open("max", "r") as f:
m = int(f.read())
b = (lambda: "foo") if int(input("Pick a number: ")) % m > random.randint(0, m) else None
- deleted 3y ago[deleted]
- em-bee 3y agofair point, but this is why you need multiple parse steps. first parse you get the overall structure and note where forward references are made to things that are not known yet. in the second step you fill in those references as found. it becomes problematic if a function definition is conditional. i suppose then that the compilation should fail because i guess conditional definitions would not be covered.