Gist 70c868110a00f3ba70900612538f1fce
✓ Published0🌍 Public
Aalpha-beta-soup
Last edited Mar 23, 2017
Created on Mar 23, 2017
This example demonstrates a unit-validation function that checks whether a string represents a valid Pint unit. It defines `is_str_valid_pint_unit` to attempt parsing the input with the Pint `UnitRegistry` and returns `False` when an `UndefinedUnitError` occurs. The code prints `True` for the sample unit `'degC'`, showing how the registry recognizes common units. The example uses the Pint library’s `ureg()` call to perform the validation.
AI-generated description