You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
548 B
20 lines
548 B
# this function makes functions
|
|
def constructor(color, size):
|
|
print(">>> constructor color:", color, "size:", size)
|
|
|
|
# watch the indent!
|
|
def repeater():
|
|
# notice this function is using color, size
|
|
print("### repeater color:", color, "size:", size)
|
|
|
|
print("<<< exit constructor");
|
|
return repeater
|
|
|
|
# what's returned are repeater functions
|
|
blue_xl = constructor("blue", "xl")
|
|
green_sm = constructor("green", "sm")
|
|
|
|
# see how these repeaters "know" the parameters?
|
|
for i in range(0,4):
|
|
blue_xl()
|
|
green_sm()
|
|
|