a-a-a-a-a
English | 中文
展开任意层级的嵌套列表、元组、集合与字典,可限深度。
安装
pip install a-a-a-a-a
用法
from a_a_a_a_a import flatten, flatten_iter
flatten([1, [2, [3, [4]]]]) # [1, 2, 3, 4]
flatten([1, [2, [3, [4]]]], 2) # [1, 2, 3, [4]]
flatten(["ab", ["cd"]]) # ['ab', 'cd']
flatten([{"a": 1}, [2]]) # [1, 2]
list(flatten_iter([1, [2]])) # [1, 2]
说明
字符串和字节视为叶子,永不拆成单字符;dict 按 value 展开;n_depth 为空表示全展开,1 只拆一层。提供 flatten_iter 流式版本,深长输入不会一次性materialize。
许可证
MIT
English
Flatten nested iterables to a chosen depth.
Install
pip install a-a-a-a-a
Usage
from a_a_a_a_a import flatten, flatten_iter
flatten([1, [2, [3, [4]]]]) # [1, 2, 3, 4]
flatten([1, [2, [3, [4]]]], 2) # [1, 2, 3, [4]]
flatten(["ab", ["cd"]]) # ['ab', 'cd']
flatten([{"a": 1}, [2]]) # [1, 2]
list(flatten_iter([1, [2]])) # [1, 2]
Notes
Strings and bytes are leaves and are never split into characters. Dicts descend into their values. n_depth=None unwraps fully, 1 unwraps one level. flatten_iter streams instead of materializing.
License
MIT
Metadata
Release files for a-a-a-a-a 0.0.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 | Provenance | |
|---|---|---|---|---|
| a_a_a_a_a-0.0.4.tar.gz | 3.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| a_a_a_a_a-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / a_a_a_a_a-0.0.4.tar.gz
| Download URL | a_a_a_a_a-0.0.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b5c87b03cd7093e69f90379d683f1b55b2ba0796e5a927115297aec04f97980
|
|
BLAKE2b-256 checksum How to use checksums |
52162723d5e211f10baac6d8fa8ca893ce89af1a9014d07ded4e357380f3943a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / a_a_a_a_a-0.0.4-py3-none-any.whl
| Download URL | a_a_a_a_a-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bdb4db04b8e45b92845f5b3c27bf3c13a93f6e4200b5d93fc1d46f6287e2422
|
|
BLAKE2b-256 checksum How to use checksums |
0cd29afc1e093fb0c1c6f01b07746a14485da9c8ac1b82046927355c619fa8dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for a-a-a-a-a 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.