PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` Kitchen.iterutils Module — kitchen 1.1.1 documentation

Kitchen.iterutils Module

Functions to manipulate iterables

New in version Kitchen:: 0.2.1a1

Module author: Toshio Kuratomi <toshio@fedoraproject.org>

Module author: Luke Macken <lmacken@redhat.com>

kitchen.iterutils.isiterable(obj, include_string=False)

Check whether an object is an iterable

Parameters:
  • obj – Object to test whether it is an iterable
  • include_string – If True and obj is a byte str or unicode string this function will return True. If set to False, byte str and unicode strings will cause this function to return False. Default False.
Returns:

True if obj is iterable, otherwise False.

kitchen.iterutils.iterate(obj, include_string=False)

Generator that can be used to iterate over anything

Parameters:
  • obj – The object to iterate over
  • include_string – if True, treat strings as iterables. Otherwise treat them as a single scalar value. Default False

This function will create an iterator out of any scalar or iterable. It is useful for making a value given to you an iterable before operating on it. Iterables have their items returned. scalars are transformed into iterables. A string is treated as a scalar value unless the include_string parameter is set to True. Example usage:

>>> list(iterate(None))
[None]
>>> list(iterate([None]))
[None]
>>> list(iterate([1, 2, 3]))
[1, 2, 3]
>>> list(iterate(set([1, 2, 3])))
[1, 2, 3]
>>> list(iterate(dict(a='1', b='2')))
['a', 'b']
>>> list(iterate(1))
[1]
>>> list(iterate(iter([1, 2, 3])))
[1, 2, 3]
>>> list(iterate('abc'))
['abc']
>>> list(iterate('abc', include_string=True))
['a', 'b', 'c']

Previous topic

Kitchen.collections

Next topic

Helpers for versioning software

This Page