justbytes._util.misc module

Miscellaneous utilities.

justbytes._util.misc.as_single_number(value, config)

Returns a rational value as a single number according to the specified configuration.

Parameters:
  • value (Rational) – a numeric value
  • config (StrConfig) – how to calculate the value to display
Returns:

the result and its relation to value

Return type:

Radix * int

justbytes._util.misc.next_or_last(pred, seq, default=None)

Return the first element that matches the predicate or the last element in the seq.

If seq is empty, return default.

Parameters:
  • pred (bool) – a predicate, return False if the value is not satisfactory
  • seq – a sequence of values
  • default – returned if seq is empty, default is None
justbytes._util.misc.relation_to_symbol(relation)

Change a numeric relation to a string symbol.

Parameters:relation (int) – the relation
Returns:a symbol with the right relation to relation
Return type:str
justbytes._util.misc.strip_trailing_zeros(value)

Strip trailing zeros from a list of ints.

Parameters:value (list of str) – the value to be stripped
Returns:list with trailing zeros stripped
Return type:list of int
justbytes._util.misc.take_until_satisfied(pred, seq)

Like next(), but yields all values until the first matching value.

Parameters:
  • pred (bool) – a predicate, return False if the value is not satisfactory
  • seq – a sequence of values

Previous topic

justbytes._util package

Next topic

justbytes._config module

This Page