vendredi 9 novembre 2018

Python - Call a Function on a Condition

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 terniary comprehension or something similiar.

if I do

(some_dataframe_df = myfunction()) if list_1 != [] else pass

It doesn't work.

Trying to get tighter code.

Thanks.

Aucun commentaire:

Enregistrer un commentaire