From cf1abf100a977e0619e3f64f83905e3dd8676fe1 Mon Sep 17 00:00:00 2001 From: Jun Omae Date: Tue, 10 May 2022 17:01:45 +0900 Subject: [PATCH] Use `... if expr else ...` --- babel/dates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babel/dates.py b/babel/dates.py index c79e9cf63..0b3732347 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -1483,7 +1483,7 @@ def format_period(self, char, num): widths = [{3: 'abbreviated', 4: 'wide', 5: 'narrow'}[max(3, num)], 'wide', 'narrow', 'abbreviated'] if char == 'a': - period = {0: 'am', 1: 'pm'}[int(self.value.hour >= 12)] + period = 'pm' if self.value.hour >= 12 else 'am' context = 'format' else: period = get_period_id(self.value, locale=self.locale)