Top "Iterable" questions

An iterable is an object, such as a string or collection, that can be iterated over, yielding up its members one at a time.

Unittest's assertEqual and iterables - only check the contents

Is there a 'decent' way in unittest to check the equality of the contents of two iterable objects? I am …

python unit-testing assert iterable
How to check if an object is iterable in Python?

How does one check if a Python object supports iteration, a.k.a an iterable object (see definition Ideally I …

python iterable
Shortest way to get first item of `OrderedDict` in Python 3

What's the shortest way to get first item of OrderedDict in Python 3? My best: list(ordered_dict.items())[0] Quite long …

python python-3.x indexing iterable
"Iterable<Element> cannot be cast to List<Element>" - Isn't `List` a type of `Iterable`?

I called a getElements method which returns Iterable<Element>. I did this: List<Element> elements = (List&…

java list classcastexception iterable
How can I make my class iterable so I can use foreach syntax?

I have Book and BookList classes. BookList is something like this: public class BookList { private final List<Book> …

java foreach iterable
Implement Java Iterator and Iterable in same class?

I am trying to understand Java Iterator and Iterable interfaces I am writing this class class MyClass implements Iterable<…

java iterator iterable
Why does Stream<T> not implement Iterable<T>?

In Java 8 we have the class Stream<T>, which curiously have a method Iterator<T> iterator() …

java java-8 java-stream iterable
What's the shortest way to count the number of items in a generator/iterator?

If I want the number of items in an iterable without caring about the elements themselves, what would be the …

python iterator generator iterable
how to convert pandas series to tuple of index and value

I'm looking for an efficient way to convert a series to a tuple of its index with its values. s = …

python pandas series iterable
Why does Iterable<T> not provide stream() and parallelStream() methods?

I am wondering why the Iterable interface does not provide the stream() and parallelStream() methods. Consider the following class: public …

java java-8 java-stream iterable