Ejemplo n.º 1
0
def filterByDates(list, date1, date2):
    """
    This function return the list with activities between given dates.
    :param list: list - initial list
    :param date1: date - date1
    :param date2: date - date2
    :return: list - filtered list
    """
    return filter(list, property=lambda x: date1 <= x.getDate().date() <= date2)
Ejemplo n.º 2
0
  def test_filter(self):
    l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    self.assertEqual(filter(l, property=lambda x: x % 3 == 1), [1, 4, 7, 10])

    l = [x for x in range(1, 1000)]
    self.assertEqual(filter(l, property=lambda x: x == sum([k for k in range(1, x-1) if x % k == 0])), [6, 28, 496])