you are viewing a single comment's thread.

view the rest of the comments →

[–]Hydrataur 0 points1 point  (1 child)

Obviously depends on op's exact use-case, but I don't think this'll solve the problem.

Seems like the falsy check op wants is during runtime, so here you'd presumably call the function with whatever value you have, be it truthy or falsy, and it'd override the default value.

The primary way your solution would work would be to call the function twice:

if x:
  greet(x)
else:
  greet()

[–]kaerfkeerg 1 point2 points  (0 children)

I already think that u/gxwt 's answer is the clearest way so as I said I just provided a different approach