lundi 4 juillet 2016

What is the pythonic way for 'do_this() if condition else do_that() '?

There is exists a pythonic way for doing somethings like that?

>> list.append(elem) if condition else pass
>> list.append(elem) if condition else other_list.append(elem)

I have needed sometimes something like that and I don't know the best way for accomplish it.

Thanks.

Aucun commentaire:

Enregistrer un commentaire