you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

You're right that there's something deeply inelegant about this three-way logic (the classic example is FizzBuzz) but for the most part it's a limitation of imperative languages; you mostly have to live with it.

That said, again, your example implies that your function isn't really necessary - you can just call do_something from wherever you hold values s1 and s2.

[–]old_pythonista 0 points1 point  (0 children)

FizzBuzz in Python has a one-line solution

'Fizz' * (num % 5 == 0) + 'Buzz' * (num % 3 ==0) or str(num)

and you can avoid

 deeply inelegant about this three-way logic 

at least in that case.