faust.utils.functional¶
Functional utilities.
- faust.utils.functional.consecutive_numbers(it: Iterable[int]) Iterator[Sequence[int]][source]¶
Find runs of consecutive numbers.
Notes
See https://docs.python.org/2.6/library/itertools.html#examples
- Return type:
_GenericAlias[_GenericAlias[int]]
- faust.utils.functional.translate(table: Mapping, s: str) str[source]¶
Replace characters and patterns in string
s.Works similar to
str.translate(), but replacements and patterns can be full length strings instead of character by character.- Parameters:
table (
_SpecialGenericAlias) – A mapping of characters/patterns to their replacement string.s (
str) – The string to translate
Note
Table is the first argument in the signature for compatibility with
partial():>>> t = partial(translate, {'.': '_'}) >>> t('foo.bar') 'foo_bar'
Examples
>>> translate('foo.bar@baz', {'.': '_', '@': '.'}) 'foo_bar.baz'
- Return type: