EliteBot/elitebot/lib/python3.11/site-packages/sqlalchemy_utils/utils.py
2024-02-19 15:34:25 +01:00

22 lines
452 B
Python

from collections.abc import Iterable
def str_coercible(cls):
def __str__(self):
return self.__unicode__()
cls.__str__ = __str__
return cls
def is_sequence(value):
return (
isinstance(value, Iterable) and not isinstance(value, str)
)
def starts_with(iterable, prefix):
"""
Returns whether or not given iterable starts with given prefix.
"""
return list(iterable)[0:len(prefix)] == list(prefix)