serhii.net

In the middle of the desert you can say anything you want

21 Jul 2022

Python str lower bug - callable function vs function return value

Spent hours tracking down a bug that boiled down to:

A if args.sth.lower == "a" else B

Guess what - args.sth.lower is a callable, and will never be equal to a string. So args.sth.lower == "a" is always False.

Of course I needed args.sth.lower().

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus