$83 GRAYBYTE WORDPRESS FILE MANAGER $93

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/alt/python313/lib64/python3.13/importlib/resources/

HOME
Current File : /opt/alt/python313/lib64/python3.13/importlib/resources//_itertools.py
# from more_itertools 9.0
def only(iterable, default=None, too_long=None):
    """If *iterable* has only one item, return it.
    If it has zero items, return *default*.
    If it has more than one item, raise the exception given by *too_long*,
    which is ``ValueError`` by default.
    >>> only([], default='missing')
    'missing'
    >>> only([1])
    1
    >>> only([1, 2])  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ValueError: Expected exactly one item in iterable, but got 1, 2,
     and perhaps more.'
    >>> only([1, 2], too_long=TypeError)  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    TypeError
    Note that :func:`only` attempts to advance *iterable* twice to ensure there
    is only one item.  See :func:`spy` or :func:`peekable` to check
    iterable contents less destructively.
    """
    it = iter(iterable)
    first_value = next(it, default)

    try:
        second_value = next(it)
    except StopIteration:
        pass
    else:
        msg = (
            'Expected exactly one item in iterable, but got {!r}, {!r}, '
            'and perhaps more.'.format(first_value, second_value)
        )
        raise too_long or ValueError(msg)

    return first_value


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
10 Feb 2026 9.35 AM
root / linksafe
0755
__pycache__
--
10 Feb 2026 9.35 AM
root / linksafe
0755
__init__.py
0.687 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
_adapters.py
4.377 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
_common.py
5.484 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
_functional.py
2.589 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
_itertools.py
1.247 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
abc.py
5.081 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
readers.py
6.097 KB
10 Jan 2026 10.38 AM
root / linksafe
0644
simple.py
2.529 KB
10 Jan 2026 10.38 AM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF