I was wondering if there is a concise way to call a function on a condition.
I have this:
if list_1 != []:
some_dataframe_df = myfunction()
I'm wondering if it is possible to this in a ternary operator or something similiar.
If I do
(some_dataframe_df = myfunction()) if list_1 != [] else pass
It doesn't work.
list != [], it's a better pattern to useif not list_1:. This will evaluate to true/false if "iterable" is empty. That allows for the correct check for all zero-lenth iterables, even it's a different type of iterable (tuble, dict keys, etc)