3 ms·
well technically, if you type-annotate the dict you should be fine: dispatch: Mapping[str, Callable[arg_types, ret_type]] = {}
by keymone 7y ago
well technically, if you type-annotate the dict you should be fine:
dispatch: Mapping[str, Callable[arg_types, ret_type]] = {}
- carapace 7y agoThat's neat. I hadn't realized type hints had gotten that good now. Cheers! I've had issues reading code where I'm trying to trace control flow and I hit some dispatch point in the code and it's suddenly really hard to tell where to go from there. I do (did) a lot of Python programming and sometimes it's a little too dynamic, ya know what I mean? :-)
- keymone 7y agotype hints got good, editors and typecheckers didn't really :) personally i like these dispatches more than giant if/switch statements for no reason other than better separation and management of logic. as for debugging - stepping through code in ipdb is still the way to go.