flati
==========
|travis| |coveralls| |pyversion| |version| |license|
Flatten nested iterable object (Pure-Python implementation)
Installation
==============
::
$ pip install flati
Usage
============
.. code:: python
import flati
iterable = [(1, 2, 3), (4, (5, 6))]
list(flati.flatten(iterable))
# => [1, 2, 3, 4, 5, 6]
# flati.flatten() returns a generator
import types
isinstance(flati.flatten(iterable), types.GeneratorType)
# => True
# If you want to avoid flattening specific type, then use "ignore" parameter
iterable = [('abc'), ('def', ('g', 'hi'))]
list(flati.flatten(iterable, ignore=str))
# => ['abc', 'def', 'g', 'hi']
Tips
------
If you want to flatten numpy.ndarray, I recommend using following methods:
* numpy.ravel()
* ndarray.reshape(-1)
* ndarray.flatten() # This method is a bit slow because it makes a copy
.. |travis| image:: https://travis-ci.org/ikegami-yukino/flati.svg?branch=master
:target: https://travis-ci.org/ikegami-yukino/flati
:alt: travis-ci.org
.. |coveralls| image:: https://coveralls.io/repos/ikegami-yukino/flati/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/ikegami-yukino/flati?branch=master
:alt: coveralls.io
.. |pyversion| image:: https://img.shields.io/pypi/pyversions/flati.svg
.. |version| image:: https://img.shields.io/pypi/v/flati.svg
:target: http://pypi.python.org/pypi/flati/
:alt: latest version
.. |license| image:: https://img.shields.io/pypi/l/flati.svg
:target: http://pypi.python.org/pypi/flati/
:alt: license
CHANGES
=======
0.1.2 (2019-12-31)
------------------
- Support Python 3.8
0.1.1 (2019-1-28)
------------------
- Support Python 2.7
0.1 (2019-1-27)
------------------
- First release
Raw data
{
"_id": null,
"home_page": "https://github.com/ikegami-yukino/flati",
"name": "flati",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "flatten,generator,pure-python",
"author": "Yukino Ikegami",
"author_email": "yknikgm@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6b/94/734b1e7640b62bdcb80e4e6ea37128efe04ef718a60a637ff8de13d7416a/flati-0.1.2.tar.gz",
"platform": "POSIX",
"description": "flati\n==========\n|travis| |coveralls| |pyversion| |version| |license|\n\nFlatten nested iterable object (Pure-Python implementation)\n\n\nInstallation\n==============\n\n::\n\n $ pip install flati\n\n\nUsage\n============\n\n.. code:: python\n\n import flati\n\n iterable = [(1, 2, 3), (4, (5, 6))]\n list(flati.flatten(iterable))\n # => [1, 2, 3, 4, 5, 6]\n\n # flati.flatten() returns a generator\n import types\n isinstance(flati.flatten(iterable), types.GeneratorType)\n # => True\n\n # If you want to avoid flattening specific type, then use \"ignore\" parameter\n iterable = [('abc'), ('def', ('g', 'hi'))]\n list(flati.flatten(iterable, ignore=str))\n # => ['abc', 'def', 'g', 'hi']\n\nTips\n------\nIf you want to flatten numpy.ndarray, I recommend using following methods:\n\n* numpy.ravel()\n* ndarray.reshape(-1)\n* ndarray.flatten() # This method is a bit slow because it makes a copy\n\n\n.. |travis| image:: https://travis-ci.org/ikegami-yukino/flati.svg?branch=master\n :target: https://travis-ci.org/ikegami-yukino/flati\n :alt: travis-ci.org\n\n.. |coveralls| image:: https://coveralls.io/repos/ikegami-yukino/flati/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/ikegami-yukino/flati?branch=master\n :alt: coveralls.io\n\n.. |pyversion| image:: https://img.shields.io/pypi/pyversions/flati.svg\n\n.. |version| image:: https://img.shields.io/pypi/v/flati.svg\n :target: http://pypi.python.org/pypi/flati/\n :alt: latest version\n\n.. |license| image:: https://img.shields.io/pypi/l/flati.svg\n :target: http://pypi.python.org/pypi/flati/\n :alt: license\n\n\nCHANGES\n=======\n\n0.1.2 (2019-12-31)\n------------------\n\n- Support Python 3.8\n\n0.1.1 (2019-1-28)\n------------------\n\n- Support Python 2.7\n\n0.1 (2019-1-27)\n------------------\n\n- First release",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Flatten nested iterable object (Pure-Python)",
"version": "0.1.2",
"split_keywords": [
"flatten",
"generator",
"pure-python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6b94734b1e7640b62bdcb80e4e6ea37128efe04ef718a60a637ff8de13d7416a",
"md5": "d471f1bc768b5c0c9b9ec2c682d952a4",
"sha256": "93b58c36864e4fb4706815bc31a20399755deea803e2e482dbb1083f20a04131"
},
"downloads": -1,
"filename": "flati-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d471f1bc768b5c0c9b9ec2c682d952a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3463,
"upload_time": "2019-12-31T04:03:02",
"upload_time_iso_8601": "2019-12-31T04:03:02.583708Z",
"url": "https://files.pythonhosted.org/packages/6b/94/734b1e7640b62bdcb80e4e6ea37128efe04ef718a60a637ff8de13d7416a/flati-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2019-12-31 04:03:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "ikegami-yukino",
"github_project": "flati",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "flati"
}