justbytes._util.generators module

Special purpose generators.

justbytes._util.generators.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.generators.takeuntil(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