diff options
Diffstat (limited to 'pint/formatting.py')
-rw-r--r-- | pint/formatting.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/pint/formatting.py b/pint/formatting.py index e9b9c3a..a04205d 100644 --- a/pint/formatting.py +++ b/pint/formatting.py @@ -139,15 +139,17 @@ def register_unit_format(name): Examples -------- - >>> @pint.register_unit_format("custom") - ... def format_custom(unit, registry, **options): - ... result = "<formatted unit>" # do the formatting - ... return result - ... - >>> ureg = pint.UnitRegistry() - >>> u = ureg.m / ureg.s ** 2 - >>> f"{u:custom}" - '<formatted unit>' + .. code:: python + + @pint.register_unit_format("custom") + def format_custom(unit, registry, **options): + result = "<formatted unit>" # do the formatting + return result + + + ureg = pint.UnitRegistry() + u = ureg.m / ureg.s ** 2 + f"{u:custom}" """ def wrapper(func): |