SPPAS 4.20

Module sppas.src.structs

Class sppasListCompare

Description

Comparison methods for two lists.

Constructor

Create a new instance.

View Source
def __init__(self):
    """Create a new instance."""
    super(sppasListCompare, self).__init__()
    self.methods['leq'] = sppasListCompare.leq
    self.methods['lne'] = sppasListCompare.lne
    self.methods['lgt'] = sppasListCompare.lgt
    self.methods['llt'] = sppasListCompare.llt
    self.methods['lle'] = sppasListCompare.lle
    self.methods['lge'] = sppasListCompare.lge

Public functions

leq

Return True if number of elements in the list is equal to x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def leq(elements, x):
    """Return True if number of elements in the list is equal to x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) == x
lne

Return True if number of elements in the list is not equal to x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def lne(elements, x):
    """Return True if number of elements in the list is not equal to x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) != x
lgt

Return True if number of elements in the list is greater than x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def lgt(elements, x):
    """Return True if number of elements in the list is greater than x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) > x
llt

Return True if number of elements in the list is lower than x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def llt(elements, x):
    """Return True if number of elements in the list is lower than x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) < x
lge

Return True if number of elements in the list is greater or equal than x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def lge(elements, x):
    """Return True if number of elements in the list is greater or equal than x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) >= x
lle

Return True if number of elements in the list is lower or equal than x.

Parameters
  • elements: (list)
  • x: (int)
Returns
  • (bool)
View Source
@staticmethod
def lle(elements, x):
    """Return True if number of elements in the list is lower or equal than x.

        :param elements: (list)
        :param x: (int)
        :returns: (bool)

        """
    if isinstance(elements, (list, tuple)) is False:
        raise sppasTypeError(elements, 'list')
    if sppasType().is_number(x) is False:
        raise sppasTypeError(x, 'int/float')
    x = int(x)
    return len(elements) <= x