79695299

Date: 2025-07-09 08:11:49
Score: 1
Natty:
Report link

A slightly cursed "improvement" to attila's answer would be

@lambda f: lambda *args: dict(f(*args))
def optional_oranges(apple, orange = None):
    yield "apple", apple
    if orange is not None:
        yield "orange", orange

optional_oranges(1) #{'apple': 1}
optional_oranges(1,2) #{'apple': 1, 'orange': 2}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Saajmen