约 52 个结果
在新选项卡中打开链接
  1. What are iterator, iterable, and iteration? - Stack Overflow

    So an iterable is an object that you can get an iterator from. An iterator is an object with a next (Python 2) or __next__ (Python 3) method. Whenever you use a for loop, or map, or a list comprehension, …

  2. Python: how to determine if an object is iterable?

    Checking isinstance(obj, Iterable) detects classes that are registered as Iterable or that have an __iter__() method, but it does not detect classes that iterate with the __getitem__() method. The only …

  3. What exactly does "iterable" mean in Python? Why isn't my object …

    First I want to clarify, I'm NOT asking what is "iterator". This is how the term "iterable" is defined in Python's doc: iterable An object capable of returning its members one at a time.

  4. java - What is the difference between iterator and iterable and how to ...

    An Iterable is a simple representation of a series of elements that can be iterated over. It does not have any iteration state such as a "current element". Instead, it has one method that produces an Iterator. …

  5. TypeError: 'NoneType' object is not iterable - Stack Overflow

    2023年11月12日 · For example if data is a value returned from a function, then make sure that function returns an iterable object (such as list, numpy ndarray, pandas DataFrame etc.). If data is the value …

  6. how to tell a variable is iterable but not a string

    I notice that the implementation of Iterable, now in _collections_abc.py, has changed so it also checks that the required __iter__ method isn't just None. And am I right in thinking this is equivalent to using …

  7. Java 8 Iterable.forEach() vs foreach loop - Stack Overflow

    2013年5月19日 · When running with "-client", Iterable#forEach outperforms the traditional for loop over an ArrayList, but is still slower than directly iterating over an array.

  8. python - How to build a basic iterator? - Stack Overflow

    If you want to be able to iterate ctr more than once, it needs to be a non-iterator iterable, where it returns a brand new iterator each time __iter__ is invoked. Trying to mix and match (an iterator that is …

  9. Checking whether something is iterable - Stack Overflow

    2013年9月19日 · As a sidenote, BEWARE about the definition of iterable. If you're coming from other languages you would expect that something you can iterate over with, say, a for loop is iterable. I'm …

  10. Python type hint for Iterable[str] that isn't str - Stack Overflow

    2022年3月29日 · In Python, is there a way to distinguish between strings and other iterables of strings? A str is valid as an Iterable[str] type, but that may not be the correct input for a function. For example, in