Skip to content

Commit

Permalink
Added the code for the single dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
pandeytapan committed Oct 24, 2024
1 parent 20e6980 commit 6a79458
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fluent/chap.07/code/htmldispatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from functools import singledispatch
import html
from typing import Any

# singledispatch marks the function that will handle the base type


@singledispatch
def htmlize(obj: Any):
content = html.escape(repr(obj))
return '<pre>{}</pre>'.format(content)

0 comments on commit 6a79458

Please sign in to comment.