Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/past/builtins/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s&dZddlmZmZmZddlmZmZddlZddlm Z ddl
mZd�Zer�ddl
Z
d�Zd �Zd
�Zd�ZeZeZeZddlmZeZd
ddddgZn?ddlZejZejZejZejZejZgZdS(s,
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``
i(tdivisiontabsolute_importtprint_function(tchaintstarmapN(t
basestring(tPY3cC`stjt||��S(N(Rt
from_iterabletmap(tftitems((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pytflatmapscG`st|d�}t|dt�r<|�jtj|��St|dttf�rh|tj|��Sttj|��SdS(s*
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.
iN(ttypet
isinstanceRtjointbuiltinstfilterttupletlist(targstmytype((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pyt oldfilter$scG`s�tj|�}t|�}t|�dkr1gS|dkrF|}ntt||��}yBtg|D]}t|�^qh�dkr�ttj|��SWnt k
r�}nX|S(s
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.
iiN(
t itertoolstzip_longestRtlentNoneRtmaxRRt TypeError(tfunct iterablestzippedtltresulttitemte((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pytoldmap8s +cO`sttj||��S(N(RRtrange(Rtkwargs((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pytoldrange�scO`sttj||��S(N(RRtzip(RR%((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pytoldzip�s(treduceRRR$R)R'(t__doc__t
__future__RRRRRRt
past.typesRt
past.utilsRRRRR#R&R(RRR$t functoolsR)R't__all__t__builtin__(((s>/usr/lib/python2.7/site-packages/past/builtins/noniterators.pyt<module>s2 �