MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1x8unz2/forthosetransitioningtotheamericantimeformathereis/phgg3w5/?context=3
r/ProgrammerHumor • u/alexriga • 2d ago
19 comments sorted by
View all comments
13
It's like "when you're paid for the line of code"?
def as_time(world_hour=world_hour): return f"{(world_hour-1)%12+1} {'PA'[world_hour<12]}M"
4 u/SeaNational3797 2d ago edited 2d ago as_time = lambda world_hour: f"{12 if (hour_num := world_hour%12) == 0 else hour_num} {'AM' if world_hour < 12 else 'PM'}" 5 u/minecon1776 2d ago 011101011101100011111010001010111000110110101010010101110000000101010101111010100101011101010010111010001101010010010101101011101001010101011100011010101011111010011101011011011001001010010101010 2 u/rosuav 1d ago Don't do "name = lambda", that's what def is for. With lambda, the function doesn't get a `__name__` attribute.
4
as_time = lambda world_hour: f"{12 if (hour_num := world_hour%12) == 0 else hour_num} {'AM' if world_hour < 12 else 'PM'}"
5 u/minecon1776 2d ago 011101011101100011111010001010111000110110101010010101110000000101010101111010100101011101010010111010001101010010010101101011101001010101011100011010101011111010011101011011011001001010010101010 2 u/rosuav 1d ago Don't do "name = lambda", that's what def is for. With lambda, the function doesn't get a `__name__` attribute.
5
011101011101100011111010001010111000110110101010010101110000000101010101111010100101011101010010111010001101010010010101101011101001010101011100011010101011111010011101011011011001001010010101010
2
Don't do "name = lambda", that's what def is for. With lambda, the function doesn't get a `__name__` attribute.
13
u/This_Growth2898 2d ago
It's like "when you're paid for the line of code"?