Determines if an object is iterable
This function uses a couple of different methods to find out if a variable is iterable
$pip install isiter
from isiter import isiter
from collections import namedtuple
fields_cor = "qt rgb r g b"
classname_cor = "cor"
Colorinfos = namedtuple(classname_cor, fields_cor)
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
html = """
<div class="div1">
<p>hello</p>
<p>hi</p>
<div class="nesteddiv">
<p>one</p>
<p>two</p>
<p>three</p>
</div>
</div>
"""
print(f"""{isiter({1:2,3:2}, )=}""")
print(f"""{isiter([1,2,34], )=}""")
print(f"""{isiter((1,2,34), )=}""")
print(f"""{isiter(Colorinfos(1,2,34,3,3), )=}""")
print(f"""{isiter(sorted((1,2,34,3,3)), )=}""")
print(f"""{isiter(({1, 2, 34, 3, 3}), )=}""")
print(f"""{isiter((55), )=}""")
print(f"""{isiter((55.44), )=}""")
print(f"""{isiter((True), )=}""")
print(f"""{isiter((3.14 + 2.71j), )=}""")
print(f"""{isiter((pd.DataFrame([[3,3,3],[3,3,3]])), )=}""")
print(f"""{isiter((pd.Series([[3,3,3]])), )=}""")
print(f"""{isiter((np.array([[3,3,3]])), )=}""")
print(f"""{isiter((np.ndarray([3,3,3])), )=}""")
print(f"""{isiter((pd.NA), )=}""")
print(f"""{isiter((np.nan), )=}""")
print(f"""{isiter(BeautifulSoup(html, 'lxml'), )=}""")
print(f"""{isiter(bytearray(b'dgfasds'), )=}""")
print(
f"""{isiter(bytearray(b'dgfasds'),consider_non_iter=(str, bytes, bytearray) )=}"""
)
print(f"""{isiter(b'bababa', )=}""")
print(f"""{isiter(b'bababa',consider_non_iter=(str, bytes, bytearray) )=}""")
print(f"""{isiter('str1', )=}""")
print(f"""{isiter('str2',consider_non_iter=(str, bytes, bytearray))=}""")
{1: 2, 3: 2} in (list, tuple, set, frozenset, dict)
isiter({1:2,3:2}, )=True
[1, 2, 34] in (list, tuple, set, frozenset, dict)
isiter([1,2,34], )=True
(1, 2, 34) in (list, tuple, set, frozenset, dict)
isiter((1,2,34), )=True
cor(qt=1, rgb=2, r=3 in (list, tuple, set, frozenset, dict)
isiter(Colorinfos(1,2,34,3,3), )=True
[1, 2, 3, 3, 34] in (list, tuple, set, frozenset, dict)
isiter(sorted((1,2,34,3,3)), )=True
{1, 2, 3, 34} in (list, tuple, set, frozenset, dict)
isiter(({1, 2, 34, 3, 3}), )=True
55 in (int, float, bool, complex, type(None))
isiter((55), )=False
55.44 in (int, float, bool, complex, type(None))
isiter((55.44), )=False
True in (int, float, bool, complex, type(None))
isiter((True), )=False
(3.14+2.71j) in (int, float, bool, complex, type(None))
isiter((3.14 + 2.71j), )=False
0 1 2
0 3 3 == Iterable
isiter((pd.DataFrame([[3,3,3],[3,3,3]])), )=True
0 [3, 3, 3]
dtype == Iterable
isiter((pd.Series([[3,3,3]])), )=True
array([[3, 3, 3]]) == Iterable
isiter((np.array([[3,3,3]])), )=True
array([[[6.23042070e == Iterable
isiter((np.ndarray([3,3,3])), )=True
<NA> not iter
isiter((pd.NA), )=False
nan in (int, float, bool, complex, type(None))
isiter((np.nan), )=False
<html><body><div cla == Iterable
isiter(BeautifulSoup(html, 'lxml'), )=True
bytearray(b'dgfasds' == Iterable
isiter(bytearray(b'dgfasds'), )=True
bytearray(b'dgfasds' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)
isiter(bytearray(b'dgfasds'),consider_non_iter=(str, bytes, bytearray) )=False
b'bababa' == Iterable
isiter(b'bababa', )=True
b'bababa' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)
isiter(b'bababa',consider_non_iter=(str, bytes, bytearray) )=False
'str1' == Iterable
isiter('str1', )=True
'str2' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)
isiter('str2',consider_non_iter=(str, bytes, bytearray))=False
Metadata
Release files for isiter 0.10
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 | Actions |
|---|---|---|---|---|
| isiter-0.10.tar.gz | 4.4 kB | Without provenance | Details for isiter-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| isiter-0.10-py3-none-any.whl | Python 3 | none | any | Details for isiter-0.10-py3-none-any.whl |
Total release size: 10.3 kB
Release files / isiter-0.10.tar.gz
| Download URL | isiter-0.10.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cc54796fe5204ab6e663c6d49369787aadd56d095f0b539f875ab3c02cc96bd
|
|
BLAKE2b-256 checksum How to use checksums |
282b375eca80f41b8fa7a068096f0fb942a2a3718e88e105509209139b9f15fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / isiter-0.10-py3-none-any.whl
| Download URL | isiter-0.10-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
252a0c669236ab1bd4d99f9f2294a81b6c3a24707a93d6774813d316dd5b0599
|
|
BLAKE2b-256 checksum How to use checksums |
c1457ac7e3812eea8253c1f9aaddb808d7c3e5631b2684b36f8c019a53919576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for isiter 0.10
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.