# Determines if an object is iterable
## This function uses a couple of different methods to find out if a variable is iterable
```python
$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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/isiter",
"name": "isiter",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "iterable",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/28/2b/375eca80f41b8fa7a068096f0fb942a2a3718e88e105509209139b9f15fe/isiter-0.10.tar.gz",
"platform": null,
"description": "\n# Determines if an object is iterable\n\n## This function uses a couple of different methods to find out if a variable is iterable\n\n```python\n$pip install isiter\nfrom isiter import isiter\n\nfrom collections import namedtuple\nfields_cor = \"qt rgb r g b\"\nclassname_cor = \"cor\"\nColorinfos = namedtuple(classname_cor, fields_cor)\nimport pandas as pd\nimport numpy as np\nfrom bs4 import BeautifulSoup\n\nhtml = \"\"\"\n<div class=\"div1\">\n<p>hello</p>\n<p>hi</p>\n <div class=\"nesteddiv\">\n <p>one</p>\n <p>two</p>\n <p>three</p>\n </div>\n</div>\n\"\"\"\n\nprint(f\"\"\"{isiter({1:2,3:2}, )=}\"\"\")\nprint(f\"\"\"{isiter([1,2,34], )=}\"\"\")\nprint(f\"\"\"{isiter((1,2,34), )=}\"\"\")\nprint(f\"\"\"{isiter(Colorinfos(1,2,34,3,3), )=}\"\"\")\nprint(f\"\"\"{isiter(sorted((1,2,34,3,3)), )=}\"\"\")\nprint(f\"\"\"{isiter(({1, 2, 34, 3, 3}), )=}\"\"\")\nprint(f\"\"\"{isiter((55), )=}\"\"\")\nprint(f\"\"\"{isiter((55.44), )=}\"\"\")\nprint(f\"\"\"{isiter((True), )=}\"\"\")\nprint(f\"\"\"{isiter((3.14 + 2.71j), )=}\"\"\")\nprint(f\"\"\"{isiter((pd.DataFrame([[3,3,3],[3,3,3]])), )=}\"\"\")\nprint(f\"\"\"{isiter((pd.Series([[3,3,3]])), )=}\"\"\")\nprint(f\"\"\"{isiter((np.array([[3,3,3]])), )=}\"\"\")\nprint(f\"\"\"{isiter((np.ndarray([3,3,3])), )=}\"\"\")\nprint(f\"\"\"{isiter((pd.NA), )=}\"\"\")\nprint(f\"\"\"{isiter((np.nan), )=}\"\"\")\nprint(f\"\"\"{isiter(BeautifulSoup(html, 'lxml'), )=}\"\"\")\nprint(f\"\"\"{isiter(bytearray(b'dgfasds'), )=}\"\"\")\nprint(\n f\"\"\"{isiter(bytearray(b'dgfasds'),consider_non_iter=(str, bytes, bytearray) )=}\"\"\"\n)\nprint(f\"\"\"{isiter(b'bababa', )=}\"\"\")\nprint(f\"\"\"{isiter(b'bababa',consider_non_iter=(str, bytes, bytearray) )=}\"\"\")\nprint(f\"\"\"{isiter('str1', )=}\"\"\")\nprint(f\"\"\"{isiter('str2',consider_non_iter=(str, bytes, bytearray))=}\"\"\")\n\n\n\n{1: 2, 3: 2} in (list, tuple, set, frozenset, dict)\nisiter({1:2,3:2}, )=True\n[1, 2, 34] in (list, tuple, set, frozenset, dict)\nisiter([1,2,34], )=True\n(1, 2, 34) in (list, tuple, set, frozenset, dict)\nisiter((1,2,34), )=True\ncor(qt=1, rgb=2, r=3 in (list, tuple, set, frozenset, dict)\nisiter(Colorinfos(1,2,34,3,3), )=True\n[1, 2, 3, 3, 34] in (list, tuple, set, frozenset, dict)\nisiter(sorted((1,2,34,3,3)), )=True\n{1, 2, 3, 34} in (list, tuple, set, frozenset, dict)\nisiter(({1, 2, 34, 3, 3}), )=True\n55 in (int, float, bool, complex, type(None))\nisiter((55), )=False\n55.44 in (int, float, bool, complex, type(None))\nisiter((55.44), )=False\nTrue in (int, float, bool, complex, type(None))\nisiter((True), )=False\n(3.14+2.71j) in (int, float, bool, complex, type(None))\nisiter((3.14 + 2.71j), )=False\n 0 1 2\n0 3 3 == Iterable\nisiter((pd.DataFrame([[3,3,3],[3,3,3]])), )=True\n0 [3, 3, 3]\ndtype == Iterable\nisiter((pd.Series([[3,3,3]])), )=True\narray([[3, 3, 3]]) == Iterable\nisiter((np.array([[3,3,3]])), )=True\narray([[[6.23042070e == Iterable\nisiter((np.ndarray([3,3,3])), )=True\n<NA> not iter\nisiter((pd.NA), )=False\nnan in (int, float, bool, complex, type(None))\nisiter((np.nan), )=False\n<html><body><div cla == Iterable\nisiter(BeautifulSoup(html, 'lxml'), )=True\nbytearray(b'dgfasds' == Iterable\nisiter(bytearray(b'dgfasds'), )=True\nbytearray(b'dgfasds' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)\nisiter(bytearray(b'dgfasds'),consider_non_iter=(str, bytes, bytearray) )=False\nb'bababa' == Iterable\nisiter(b'bababa', )=True\nb'bababa' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)\nisiter(b'bababa',consider_non_iter=(str, bytes, bytearray) )=False\n'str1' == Iterable\nisiter('str1', )=True\n'str2' in (<class 'str'>, <class 'bytes'>, <class 'bytearray'>)\nisiter('str2',consider_non_iter=(str, bytes, bytearray))=False\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Checks if a variable is iterable",
"version": "0.10",
"split_keywords": [
"iterable"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "6bb281aa1d9e9d46776fea40ec97dc9d",
"sha256": "252a0c669236ab1bd4d99f9f2294a81b6c3a24707a93d6774813d316dd5b0599"
},
"downloads": -1,
"filename": "isiter-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bb281aa1d9e9d46776fea40ec97dc9d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5916,
"upload_time": "2022-12-31T12:15:13",
"upload_time_iso_8601": "2022-12-31T12:15:13.414167Z",
"url": "https://files.pythonhosted.org/packages/c1/45/7ac7e3812eea8253c1f9aaddb808d7c3e5631b2684b36f8c019a53919576/isiter-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "aa10c7fe07d09f96897bf7e9e731a9e7",
"sha256": "8cc54796fe5204ab6e663c6d49369787aadd56d095f0b539f875ab3c02cc96bd"
},
"downloads": -1,
"filename": "isiter-0.10.tar.gz",
"has_sig": false,
"md5_digest": "aa10c7fe07d09f96897bf7e9e731a9e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4422,
"upload_time": "2022-12-31T12:15:14",
"upload_time_iso_8601": "2022-12-31T12:15:14.961001Z",
"url": "https://files.pythonhosted.org/packages/28/2b/375eca80f41b8fa7a068096f0fb942a2a3718e88e105509209139b9f15fe/isiter-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-31 12:15:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "isiter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "isiter"
}