Last active
March 23, 2017 02:48
-
-
Save alpha-beta-soup/70c868110a00f3ba70900612538f1fce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pint | |
ureg = pint.UnitRegistry() | |
def is_str_valid_pint_unit(unit): | |
try: | |
ureg(unit) | |
except pint.errors.UndefinedUnitError: | |
return False | |
return True | |
def main(): | |
print(is_str_valid_pint_unit('degC')) # True | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment