Metadata-Version: 1.1
Name: split
Version: 0.4
Summary: Functions to split or partition sequences.
Home-page: https://bitbucket.org/astanin/python-split
Author: Sergey Astanin
Author-email: s.astanin@gmail.com
License: Copyright (c) 2011-2016 Sergey Astanin

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Description: ============
        python-split
        ============
        
        Functions to split and partition sequences.
        
        Installation
        ------------
        
        ::
        
            pip install split
        
        Usage
        -----
        
        All functions in this module return iterators, and consume input
        lazily. In the examples below, the results are forced using ``list``
        and ``dict``.
        
        Chunks of equal size
        ~~~~~~~~~~~~~~~~~~~~
        
        To partition a sequence into chunks of equal size, use ``chop``::
        
            >>> from split import chop
            >>> list(chop(3, range(10)))
            [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
        
        If ``truncate=True`` keyword argument is given, then sequence length is
        truncated to a multiple of chunk size, and all chunks have the same
        size::
        
            >>> list(chop(3, range(10), truncate=True))
            [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
        
        Subsequences by a predicate
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        To split a sequence into two by a given predicate, use ``partition``::
        
            >>> from split import partition
            >>> def odd(x): return x%2
            >>> map(list, partition(odd, range(5)))
            [[1, 3], [0, 2, 4]]
        
        For more general partitioning, use ``groupby``::
        
            >>> [(k, list(i)) for k,i in groupby(lambda x: x%3, range(7))]
            [(0, [0, 3, 6]), (1, [1, 4]), (2, [2, 5])]
        
        This function is different from ``itertools.groupby``: it returns only
        one subsequence iterator per predicate value. Its return value can be
        converted into dictionary.
        
        When working with very long sequences, consider using
        ``predicate_values`` keyword argument to avoid scanning the entire
        sequence. For example::
        
            >>> longseq = xrange(int(1e9))
            >>> pred = lambda x: x%3
            >>> dict(groupby(pred, longseq, predicate_values=(0,1,2)))
            {0: <generator object subsequence at 0x301b7d0>,
             1: <generator object subsequence at 0x301b780>,
             2: <generator object subsequence at 0x301b730>}
        
        Breaking on separators
        ~~~~~~~~~~~~~~~~~~~~~~
        
        To break a sequence into chunks on some separators, use ``split``. For
        example, breaking on zero elements::
        
            >>> list(split(0, [1,2,3,0,4,5,0,0,6]))
            [[1, 2, 3], [4, 5], [], [6]]
        
        You can use a function as a predicate too::
        
            >>> list(split(lambda x: x==5, range(10)))
            [[0, 1, 2, 3, 4], [6, 7, 8, 9]]
        
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
