관리-도구
편집 파일: _itertools.cpython-38.pyc
U +�e � @ s* d dl mZ ddd�Zeeffdd�ZdS )� )�filterfalseNc c sb t � }|j}|dkr6t|j| �D ]}||� |V q n(| D ]"}||�}||kr:||� |V q:dS )zHList unique elements, preserving order. Remember all elements ever seen.N)�set�addr �__contains__)�iterable�key�seenZseen_add�element�k� r �K/opt/hc_python/lib/python3.8/site-packages/importlib_metadata/_itertools.py�unique_everseen s r c C sZ | dkrt d�S |dk r,t| |�r,t | f�S z t | �W S tk rT t | f� Y S X dS )ax If *obj* is iterable, return an iterator over its items:: >>> obj = (1, 2, 3) >>> list(always_iterable(obj)) [1, 2, 3] If *obj* is not iterable, return a one-item iterable containing *obj*:: >>> obj = 1 >>> list(always_iterable(obj)) [1] If *obj* is ``None``, return an empty iterable: >>> obj = None >>> list(always_iterable(None)) [] By default, binary and text strings are not considered iterable:: >>> obj = 'foo' >>> list(always_iterable(obj)) ['foo'] If *base_type* is set, objects for which ``isinstance(obj, base_type)`` returns ``True`` won't be considered iterable. >>> obj = {'a': 1} >>> list(always_iterable(obj)) # Iterate over the dict's keys ['a'] >>> list(always_iterable(obj, base_type=dict)) # Treat dicts as a unit [{'a': 1}] Set *base_type* to ``None`` to avoid any special handling and treat objects Python considers iterable as iterable: >>> obj = 'foo' >>> list(always_iterable(obj, base_type=None)) ['f', 'o', 'o'] Nr )�iter� isinstance� TypeError)�objZ base_typer r r �always_iterable s ) r )N)� itertoolsr r �str�bytesr r r r r �<module> s