From: Vincent Le Gallic Date: Tue, 25 Jun 2013 01:40:41 +0000 (+0200) Subject: def exists ? U know, any is implemented in python -_- X-Git-Url: http://gitweb.pimeys.fr/?p=today.git;a=commitdiff_plain;h=c8d412acbdb5cd25d571185b1425d860ffb82c96 def exists ? U know, any is implemented in python -_- --- diff --git a/today.py b/today.py index c08f8e6..4522d07 100755 --- a/today.py +++ b/today.py @@ -110,13 +110,6 @@ def get_timers(): timers = add_title(u"Timers", timers) return timers -def exists(l): - """Renvoie True si au moins un élément de l est vrai""" - for i in l: - if i: - return True - return False - def get_birthdays(*search): """Obtenir la liste des anniversaires à venir, ou la liste des anniversaires correspondants à une recherche""" @@ -143,7 +136,7 @@ def get_birthdays(*search): search = [i.lower() for i in search] tous = ("--all" in search) for date, nom in liste: - if tous or exists([term.lower() in nom.lower() for term in search]): + if tous or any([term.lower() in nom.lower() for term in search]): thisyeardate = datetime.datetime(now.year, date.month, date.day) delta = thisyeardate - now + datetime.timedelta(1) age = now.year - date.year @@ -194,7 +187,7 @@ def get_saints(): for day in ["today", "tomorrow"]: ssaints = saints[day] for (sexe, saint) in ssaints: - if exists([firstname.lower() in saint.lower().split() for firstname in firstnames]): + if any([firstname.lower() in saint.lower().split() for firstname in firstnames]): towish[day].append(sexe + saint) ttowish = [] if towish["today"]: