2 ms·
I wish python had case statements for this very problem. If the statement blocks can be defined by a common function signature, your example could use {'star
by jquast 10y ago
I wish python had case statements for this very problem. If the statement blocks can be defined by a common function signature, your example could use
{'start': fn_start,
'stop': fn_stop,
}.get(
argv[1] if len(argv) > 1 else None,
fn_undefined
)(*args, **kwargs)
I used this in a demonstration terminal nibbles/worms video game clone, https://github.com/jquast/blessed/blob/master/bin/worms.py#L76-L93 https://github.com/jquast/blessed/blob/master/bin/worms.py#L...