Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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/", 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment