Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created August 24, 2016 16:26
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 tbielawa/2fdc7fa45d6a5cf6d8d6da9324a12b98 to your computer and use it in GitHub Desktop.
Save tbielawa/2fdc7fa45d6a5cf6d8d6da9324a12b98 to your computer and use it in GitHub Desktop.
Examples of bitmath 1.3.1 - Unsafe Unit Parsing
>>> import bitmath
>>> parsed = bitmath.parse_string('100k')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tbielawa/lib/python/bitmath/__init__.py", line 1396, in parse_string
raise ValueError("The unit %s is not a valid bitmath unit" % unit)
ValueError: The unit k is not a valid bitmath unit
>>> parsed = bitmath.parse_string_unsafe('100k')
>>> parsed == bitmath.kB(100)
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment