Given a list of nested lists/tuples, returns all the elements in a single list. Typical usage:
#!/usr/bin/env python from flatten.flatten import flattenlist the_list = [[1,2,3],[4,5,6], [7], [8,9]] flattenlist(the_list) [1, 2, 3, 4, 5, 6, 7, 8, 9]
Short Intro
There are already many implementations of this problem, given below.
Enthought Matplotlib. If you have matplotlib installed or Enthought Canopy.The flatten module using:
from matplotlib.cbook import flatten
The main recipie for above code given here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294
An attempt using this module is made in this stackoverflow problem:
http://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python/20400584#20400584
FlattenList is a vanilla python attempt to get the same result without any external module overhead.
Release files for FlattenList 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| FlattenList-0.1.4.zip | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| FlattenList-0.1.4-py2-none-any.whl | Python 2 | none | any | Details |
Total release size:9.2 kB
Release files / FlattenList-0.1.4.zip
| Download URL | FlattenList-0.1.4.zip |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f355e71557c89c7c792fa81b6fe5b9a7eabcaaff294408638f66230fde936e0e
|
|
BLAKE2b-256 checksum How to use checksums |
c82bd1dff7f6ed07af9f20df74066173ecaa2a0066f0582c1691d04ae94fbe09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / FlattenList-0.1.4-py2-none-any.whl
| Download URL | FlattenList-0.1.4-py2-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
d5728b086ac5dd135c906bf1ff45e9f504ee51d42430585f19414a3de351ee51
|
|
BLAKE2b-256 checksum How to use checksums |
79a81dd0aa339685bd7a50180925a1b482a0ebe5a8b0b81fca85cb3ad3d240e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |