a 97aš$ã@sÐdZddlmZmZmZddlmZmZddlZddlm Z ddl m Z dd„Z e r¢ddl Z d d „Zd d „Zd d„Zdd„ZeZeZeZddlmZeZgd¢Zn*ddlZejZejZejZejZejZgZdS)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)ÚPY3cCst t||ƒ¡S©N)rÚ from_iterableÚmap)ÚfÚitems©rúu/private/var/folders/s6/9n5zrl012gv99k63s4q6ccsd4s6mqz/T/pip-target-f5cq3f2q/lib/python/past/builtins/noniterators.pyÚflatmapsrcGs^t|dƒ}t|dtƒr,|ƒ tj|Ž¡St|dttfƒrL|tj|ŽƒSttj|ŽƒSdS)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)ÚargsZmytyperrrÚ oldfilter$s  rc Gs’tj|Ž}t|ƒ}t|ƒdkr"gS|dur0|}ntt||ƒƒ}z*tdd„|Dƒƒdkrftt |¡ƒWSWn$tyŒ}z WYd}~n d}~00|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 test_past.test_builtins. rNcSsg|] }t|ƒ‘qSr)Úlen)Ú.0ÚitemrrrÚ Xózoldmap..r) Ú itertoolsÚ zip_longestrrrÚmaxrr Ú TypeError)ÚfuncÚ iterablesZzippedÚlÚresultÚerrrÚoldmap8s  r)cOsttj|i|¤ŽƒSr )rrÚrange©rÚkwargsrrrÚoldrangeûsr-cOsttj|i|¤ŽƒSr )rrÚzipr+rrrÚoldzipþsr/)Úreduce)rr r*r0r.)Ú__doc__Ú __future__rrrr rrZ past.typesrZ past.utilsrrrrr)r-r/rr r*Ú functoolsr0r.Ú__all__Ú __builtin__rrrrÚs4  D