sisl.utils.listify
- sisl.utils.listify = <sisl.utils.misc.Listify object>
Convert arguments to an iterable-like (any iterable, default to list)
It provides also an easy mechanism for “piping” content to a function call (for better readability).
- Parameters:
cls – the default list-like object to cast it to
Examples
>>> listify = Listify() >>> 1 | listify [1] >>> Listify(tuple)(1) (1,)
It can greatly improve readability with map constructs: >>> map(lambda x, [1]) | listify [1]
Notes
If using this to convert to tuple instances
Listify(tuple)
, please do note the problems of using a tuple as indices fornumpy.ndarray
objects.This is partly inspired by pip.