Unless Python
May 25, 2020
1 minute read

Short post! You can still read, unless you’re in a hurry.

>>> unless = lambda condition: condition is not True
>>> breakfast_is_ready = False
>>> if unless(breakfast_is_ready):
...     print("Sleeping...")
... else:
...     print("Getting up!")
...
Sleeping...
>>> breakfast_is_ready = True
>>> if unless(breakfast_is_ready):
...     print("Sleeping...")
... else:
...     print("Getting up!")
...
Getting up!

Here is Ruby/Perl’s unless conditional in Python. It’s basically a fancy “if not”.


🐋 hello there! If you enjoy this, a "Thank you" is enough.

Or you can also ...

Buy me a teaBuy me a tea

comments powered by Disqus