A small library used to obtain types for various builtin iterators.
Project description
IterTypes Library
This library has some useful types and functions used to get types of iterables. Whilst iterable types were purposely avoided by the types library, iterables offer unique types which could sometimes be useful to obtain.
Getting started
Start by importing the module:
import itertypes
There are various functions which follow the naming convention is[type]iterator.
itertypes.isstringiterator(iter("string"))
>>> True
dictionary = {1: 2, 3: 4}
iteration = iter(dictionary.items())
itertypes.isdictitemiterator(iteration)
>>> True
There's also the itertypes.isiterator function where it checks if the given
object is iterable or not.
my_variable = 5
itertypes.isiterable(my_variable)
>>> False
my_variable = ['a', 'b', 'c', 'd']
all([itertypes.isiterable(my_variable), itertypes.islistiterator(iter(my_variable))])
>>> True
Finally, there's various types which resolve to iterable types. These types can be used with isinstance, or with the equality operator and the type function.
byte = bytearray()
isinstance(iter(byte), itertypes.BytearrayIteratorType)
>>> True
iterable = iter({1: 2, 3: 4}.values())
isinstance(iterable, itertypes.DictValueIteratorType)
>>> True
Installation
Install through pip.
python -m pip install itertypes
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file itertypes-1.6.1.tar.gz.
File metadata
- Download URL: itertypes-1.6.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
070423b0ae16bb7e6ada867994af7f6cac8e3d2a8626e11acdf58415c7f502ea
|
|
| MD5 |
629153f7625892141e446602f527f16e
|
|
| BLAKE2b-256 |
3d0e66df40d7e5bd260cc2c6f1f99685945eb45566bccc7e4fc89203de45a697
|
File details
Details for the file itertypes-1.6.1-py3-none-any.whl.
File metadata
- Download URL: itertypes-1.6.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7069f572b0f0328500577489cbfdf77f63a486508fb6523c8e662f5d43eb05f5
|
|
| MD5 |
ddefc8d98d7079913fc6ddfe44b7681d
|
|
| BLAKE2b-256 |
b8780463c4d0cec51fb9c11d5acb147f996842546cd5c92a5b0f107aeb64852b
|