3 ms·
You are right — the return thing is very silly. What about this: def greet(…, bow=False): … if bow: take_a_bow() Except imagine take_a_bow()
by gorgoiler 4y ago
You are right — the return thing is very silly. What about this:
def greet(…, bow=False):
…
if bow:
take_a_bow()
Except imagine take_a_bow() instead as 10 lines of code to perform the post-greeting bow-ceremony. That code takes additional arguments regarding what kind of hand flourish to perform while bowing. The flourish_type has to be an optional argument to greet (because bow is) but inside the bow you have to assert flourish_type is not None because you can’t bow without knowing what flourish to give.
I’ve seen some dark stuff over the years.
Also: Welcome to HN!
- m3047 4y agodef greet(bow=None): ... if bow: bow() def elsewhere(gesture): def bow(): print(gesture) greet(bow) Wrap that.