Chris Angelico schrieb am 03.02.19 um 02:23: > Of course, you can also precompute this: > > day_ordinal = mapper( > [1, 21, 31], "st", > [2, 22], "nd", > [3, 23], "rd", > ) > def f(x): return day_ordinal.get(x, "th")
… in which case I would also 'precompute' the ".get" and give the resulting callable a properly readable name all-together: find_special_day_ordinal = mapper( [1, 21, 31], "st", [2, 22], "nd", [3, 23], "rd", ).get print(find_special_day_ordinal(x, "th")) Stefan -- https://mail.python.org/mailman/listinfo/python-list