iterable Questions
1
Solved
I need the index number forEach iterable value because I want to update my data table. But for updating the data table I need the column ID. That's why I want the index number for each value and as...
1
Solved
My function foo accepts an argument things which is turned into a list internally.
def foo(things):
things = list(things)
# more code
The list constructor accepts any iterable.
However, annotati...
Highoctane asked 11/4, 2020 at 10:33
5
Solved
Is there any practical difference between list(iterable) and [*iterable] in versions of Python that support the latter?
Outreach asked 27/9, 2018 at 14:34
1
On JavaScript arrays, there is the some method:
The some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value...
2
Solved
Stream inherits an iterator() method to produce an Iterator.
But I need an Iterable rather than an Iterator.
For example, given this string:
String input = "this\n" +
"that\n" +
"the_o...
Rampart asked 22/1, 2020 at 23:4
3
I found that some iterable can be repeatedly iterable:
const iterable = {
[Symbol.iterator]: function* () {
yield 1;
yield 3;
yield 5;
}
}
console.log([...iterable]);
console.lo...
Retention asked 4/1, 2020 at 22:47
2
Is the iteration order for a Pytorch Dataloader guaranteed to be the same (under mild conditions)?
For instance:
dataloader = DataLoader(my_dataset, batch_size=4,
shuffle=True, num_workers=4)
pr...
Fantom asked 12/12, 2019 at 23:35
16
Solved
Why does the Iterator interface not extend Iterable?
The iterator() method could simply return this.
Is it on purpose or just an oversight of Java's designers?
It would be convenient to be able ...
10
I have an Array of primitives, for example for int, int[] foo. It might be a small sized one, or not.
int foo[] = {1,2,3,4,5,6,7,8,9,0};
What is the best way to create an Iterable<Integer>...
7
I'm confused by Python's for loop syntax. Consider a code example like:
for party in feed.entry:
print(party.location.address.text)
What does for party in feed.entry actually mean, given that fee...
6
Solved
Is there any way to check if an arbitrary variable type is iterable?
So to check if it has indexed elements or I can actually loop over it's children? (Use foreach for example?)
Is it possible t...
Jankell asked 11/12, 2012 at 23:19
10
Solved
I need to figure out the number of elements in an Iterable in Java.
I know I can do this:
Iterable values = ...
it = values.iterator();
while (it.hasNext()) {
it.next();
sum++;
}
I could also ...
2
Solved
How does the 'yield' keyword in python really work, especially when it comes with recursion?
I'm using python to flatten a nested list, like [1,2,[3,4,[5,[[6,7]]]]], I want to create an generator so I can use for loop to print all the numbers one by one in the nested list. But it just does...
3
Solved
I have a java.lang.Iterable (in fact, a com.google.gson.JsonArray instance).
I would like to enumerate the items in the list using freemarker (2.3.16).
[#assign sports = controller.sports]
[#-- A...
Ilene asked 31/5, 2011 at 17:7
2
Solved
I would like to "beautify" the output of one of my Dart scripts, like so:
-----------------------------------------
OpenPGP signing notes from key `CD42FF00`
-----------------------------...
Dymphia asked 9/2, 2014 at 15:29
4
Solved
I am trying to implement an iterable proxy for a web resource (lazily fetched images).
Firstly, I did (returning ids, in production those will be image buffers)
def iter(ids=[1,2,3]):
for id in ...
Buxom asked 21/5, 2019 at 11:10
0
I was wondering why the isinstance function works with collections.Iterable for checking whether the object is iterable, if it isn't a subclass of Iterable.
If we have two classes:
class first_cl...
Lally asked 17/2, 2019 at 21:37
1
Solved
I've never used generators in PHP before and there are no examples in the documentation that show the return type declaration.
In PhpStorm, there is an error in the IDE when I do this:
public fun...
Tour asked 9/2, 2019 at 6:28
2
Solved
Preface
I have a test where I'm working with nested iterables (by nested iterable I mean iterable with only iterables as elements).
As a test cascade consider
from itertools import tee
from typ...
Rocca asked 14/12, 2018 at 18:42
5
Say you have an array-like Javascript ES6 Iterable that you know in advance will be finite in length, what's the best way to convert that to a Javascript Array?
The reason for doing so is that man...
Algo asked 23/12, 2014 at 0:58
1
Solved
I found that in Python both collections.Iterable and typing.Iterable can be used in type annotation and checking for whether an object is iterable, i.e., both isinstance(obj, collections.Iterable) ...
Thetic asked 16/10, 2018 at 3:14
1
Solved
As you may know, implementing a __getitem__ method makes a class iterable:
class IterableDemo:
def __getitem__(self, index):
if index > 3:
raise IndexError
return index
demo = IterableDem...
4
Solved
I'm a little confused over the difference between iterators and iterables. I've done a lot of reading and have got this much:
Iterator: An object that has __next__ in it’s class. You can call next...
Laguna asked 2/9, 2018 at 8:47
2
Solved
In Python 3, it is standard procedure to make a class an iterable and iterator at the same time by defining both the __iter__ and __next__ methods. But I have problems to wrap my head around this. ...
Salian asked 28/8, 2018 at 10:54
2
I would like to define a class so that its instances can be casted to both tuple and dict. An example:
class Point3:
...
p = Point(12, 34, 56)
tuple(p) # gives (12, 34, 56)
dict(p) # gives { 'x...
Crab asked 23/7, 2018 at 18:12
© 2022 - 2024 — McMap. All rights reserved.