Skip to content

Instantly share code, notes, and snippets.

@alpha-beta-soup
Last active March 23, 2017 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alpha-beta-soup/70c868110a00f3ba70900612538f1fce to your computer and use it in GitHub Desktop.
Save alpha-beta-soup/70c868110a00f3ba70900612538f1fce to your computer and use it in GitHub Desktop.
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