<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def iec2bytes(size_spec, only_positive=True):
 """ Convert a size specification, optionally containing a scaling unit in IEC notation, to a number of bytes. Parameters: size_spec (str):
 Number, optionally followed by a unit. only_positive (bool):
 Allow only positive values? Return: Numeric bytes size. Raises: ValueError: Unknown unit specifiers, or bad leading integer. """

    scale = 1
    try:
        size = int(0 + size_spec)  # return numeric values as-is
    except (TypeError, ValueError):
        spec = size_spec.strip().lower()

        for exp, iec_unit in enumerate(IEC_UNITS[1:], 1):
            iec_unit = iec_unit.lower()
            if spec.endswith(iec_unit):
                spec = spec[:-len(iec_unit)]
                scale = 2 ** (10 * exp)
                break
            elif spec.endswith(iec_unit[0]):
                spec = spec[:-1]
                scale = 2 ** (10 * exp)
                break
        else:
            if spec.endswith('b'):
                spec = spec[:-1]

        try:
            if '.' in spec:
                size = float(spec.strip())
            else:
                size = int(spec.strip(), base=0)
        except (TypeError, ValueError) as cause:
            raise ValueError('Invalid bytes size specification {!r}: {}'.format(size_spec, cause))

    if only_positive and size < 0:
        raise ValueError('Invalid negative bytes size specification {!r}'.format(size_spec))

    return int(size * scale)