관리-도구
편집 파일: noniterators.cpython-37.pyc
B �A�[�$ � @ s� d Z ddlmZmZmZ ddlmZmZ ddlZddlm Z ddl mZ dd� Zer�ddl Z d d � Zdd� Zd d� Zdd� ZeZeZeZddlmZ eZdddddgZn*ddlZejZejZejZejZejZg ZdS )a, This module is designed to be used as follows:: from past.builtins.noniterators import filter, map, range, reduce, zip And then, for example:: assert isinstance(range(5), list) The list-producing functions this brings in are:: - ``filter`` - ``map`` - ``range`` - ``reduce`` - ``zip`` � )�division�absolute_import�print_function)�chain�starmapN)� basestring)�PY3c C s t �t| |��S )N)r � from_iterable�map)�f�items� r �K/opt/alt/python37/lib/python3.7/site-packages/past/builtins/noniterators.py�flatmap s r c G s^ t | d �}t| d t�r,|� �tj| � �S t| d ttf�rL|tj| � �S ttj| � �S dS )a* filter(function or None, sequence) -> list, tuple, or string Return those items of sequence for which function(item) is true. If function is None, return the items that are true. If sequence is a tuple or string, return the same type, else return a list. � N)�type� isinstancer �join�builtins�filter�tuple�list)�argsZmytyper r r � oldfilter$ s r c G s� t j|� }t|�}t|�dkr"g S | dkr0|}ntt| |��}y(tdd� |D ��dkrdtt�|��S W n" tk r� } zW dd}~X Y nX |S )a map(function, sequence[, sequence, ...]) -> list Return a list of the results of applying the function to the items of the argument sequence(s). If more than one sequence is given, the function is called with an argument list consisting of the corresponding item of each sequence, substituting None for missing values when not all sequences have the same length. If the function is None, return a list of the items of the sequence (or a list of tuples if more than one sequence). Test cases: >>> oldmap(None, 'hello world') ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'] >>> oldmap(None, range(4)) [0, 1, 2, 3] More test cases are in past.tests.test_builtins. r Nc S s g | ]}t |��qS r )�len)�.0�itemr r r � <listcomp>X s zoldmap.<locals>.<listcomp>r ) � itertools�zip_longestr r r �maxr r � TypeError)�func� iterablesZzipped�l�result�er r r �oldmap8 s r'