Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
from functools import singledispatch @singledispatch def process(arg): print(f"Generic: {arg}") @process.register(int) def _(arg): print(f"Integer: {arg * 2}") @process.register(str) def _(arg): print(f"String: {arg.upper()}") process(5) # Integer: 10 process("hi") # String: HI
Result
Open