Skip to main content

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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a-a-a-a-a 0.0.3
File Size Uploaded Provenance
a_a_a_a_a-0.0.3.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for a-a-a-a-a 0.0.3
File Interpreter ABI Platform
a_a_a_a_a-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / a_a_a_a_a-0.0.3.tar.gz

Download URL a_a_a_a_a-0.0.3.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6bce584db123541682670c22187de9101317585879e8acf7b3826fb7d8c01ddb
BLAKE2b-256 checksum
How to use checksums
3c5bce0c890b48b001628994c2eab031a20b028691ca1d7f3699be20f290d3a1
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.3-py3-none-any.whl

Download URL a_a_a_a_a-0.0.3-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
836eff526d790b6c91ce16860112838cef612b5ed39dc9f65626daf6bfaaf412
BLAKE2b-256 checksum
How to use checksums
f6c3e9a15771694f1a38080fa171a020b522440b3e010b519b3f7420d194750f
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.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page