{ "info": { "author": "Sergey Astanin", "author_email": "s.astanin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries" ], "description": "============\npython-split\n============\n\nFunctions to split and partition sequences.\n\nInstallation\n------------\n\n::\n\n pip install split\n\nUsage\n-----\n\nAll functions in this module return iterators, and consume input\nlazily. In the examples below, the results are forced using ``list``\nand ``dict``.\n\nChunks of equal size\n~~~~~~~~~~~~~~~~~~~~\n\nTo partition a sequence into chunks of equal size, use ``chop``::\n\n >>> from split import chop\n >>> list(chop(3, range(10)))\n [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]\n\nIf ``truncate=True`` keyword argument is given, then sequence length is\ntruncated to a multiple of chunk size, and all chunks have the same\nsize::\n\n >>> list(chop(3, range(10), truncate=True))\n [[0, 1, 2], [3, 4, 5], [6, 7, 8]]\n\nSubsequences by a predicate\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo split a sequence into two by a given predicate, use ``partition``::\n\n >>> from split import partition\n >>> def odd(x): return x%2\n >>> map(list, partition(odd, range(5)))\n [[1, 3], [0, 2, 4]]\n\nFor more general partitioning, use ``groupby``::\n\n >>> [(k, list(i)) for k,i in groupby(lambda x: x%3, range(7))]\n [(0, [0, 3, 6]), (1, [1, 4]), (2, [2, 5])]\n\nThis function is different from ``itertools.groupby``: it returns only\none subsequence iterator per predicate value. Its return value can be\nconverted into dictionary.\n\nWhen working with very long sequences, consider using\n``predicate_values`` keyword argument to avoid scanning the entire\nsequence. For example::\n\n >>> longseq = xrange(int(1e9))\n >>> pred = lambda x: x%3\n >>> dict(groupby(pred, longseq, predicate_values=(0,1,2)))\n {0: ,\n 1: ,\n 2: }\n\nBreaking on separators\n~~~~~~~~~~~~~~~~~~~~~~\n\nTo break a sequence into chunks on some separators, use ``split``. For\nexample, breaking on zero elements::\n\n >>> list(split(0, [1,2,3,0,4,5,0,0,6]))\n [[1, 2, 3], [4, 5], [], [6]]\n\nYou can use a function as a predicate too::\n\n >>> list(split(lambda x: x==5, range(10)))\n [[0, 1, 2, 3, 4], [6, 7, 8, 9]]", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/astanin/python-split", "keywords": null, "license": "Copyright (c) 2011-2012 Sergey Astanin\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "split", "package_url": "https://pypi.org/project/split/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/split/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/astanin/python-split" }, "release_url": "https://pypi.org/project/split/0.4/", "requires_dist": null, "requires_python": null, "summary": "Functions to split or partition sequences.", "version": "0.4" }, "last_serial": 1913101, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "b7335dd97e4dda7ba6d3098ee6202612", "sha256": "da4407d8dc6f06261cb874f87c78b5bc9b5430bb8ef6318be7be84de772547be" }, "downloads": -1, "filename": "split-0.3.tar.gz", "has_sig": false, "md5_digest": "b7335dd97e4dda7ba6d3098ee6202612", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5149, "upload_time": "2012-10-11T00:09:49", "url": "https://files.pythonhosted.org/packages/c6/a5/a71e71286841f4dd88f794d1b61c82e2cb69c21132ed92bdac479e8f3f1e/split-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "16e72d45b66b0f8da2349be0f82d5216", "sha256": "c4be970a857d605d94999da18779bc10c34a34f937dede983268de3877b81faa" }, "downloads": -1, "filename": "split-0.4.zip", "has_sig": false, "md5_digest": "16e72d45b66b0f8da2349be0f82d5216", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7389, "upload_time": "2016-01-20T11:24:50", "url": "https://files.pythonhosted.org/packages/eb/be/58a8c908989560360b69b9cc7537c9fbe9d1fc5f791806cfc0d0eeae31f0/split-0.4.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "16e72d45b66b0f8da2349be0f82d5216", "sha256": "c4be970a857d605d94999da18779bc10c34a34f937dede983268de3877b81faa" }, "downloads": -1, "filename": "split-0.4.zip", "has_sig": false, "md5_digest": "16e72d45b66b0f8da2349be0f82d5216", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7389, "upload_time": "2016-01-20T11:24:50", "url": "https://files.pythonhosted.org/packages/eb/be/58a8c908989560360b69b9cc7537c9fbe9d1fc5f791806cfc0d0eeae31f0/split-0.4.zip" } ] }