1,318 questions
-3
votes
1
answer
109
views
iterator and iterable classes in python
Why do we return self in the iter method when we define the next method in the iterable and iterator classes?
This topic was taught in the course, but it was hard to understand and I didn't understand ...
3
votes
1
answer
98
views
Issue with a custom range when using both std::views::join and std::views::enumerate
I have a simple SequencesRange class that can iterate random genomic sequences of fixed size.
When I try to join the characters of all sequences with std::views::join, it works well, but as soon I try ...
0
votes
1
answer
49
views
Javascript: How to inspect an iterator object (iterator protocol)?
I'm trying to understand what's inside an iterator object.
Q: How can I see every property/method of an object, in this case an iteration object?
How can I see exactly of what an object is made of?
...
0
votes
1
answer
213
views
How to make TypeScript not complain about Iterator.prototype.take()?
I want to use Iterator.prototype.take() in my code but TypeScript keeps complaining it doesn't exist even though in runtime everything works as expected.
Property 'take' does not exist on type '...
0
votes
0
answers
50
views
How to declare in a *.d.ts file an Iterable of two different types? [duplicate]
This is the javascript function I'm unsuccessfully trying to make vscode show autocomplete suggestions for the returned object:
const profile = (form, validation) =>
Object.defineProperties(
{...
3
votes
7
answers
213
views
How can one combine iterables keeping only the first element with each index?
Let's say I have a number of iterables:
[[1, 2], [3, 4, 5, 6], [7, 8, 9], [10, 11, 12, 13, 14]]
How can I get only each element that is the first to appear at its index in any of the iterables? In ...
0
votes
0
answers
118
views
How to use Stream.collect with specific class as suplider
I am a student.
You might think I'm overloading the code with this, unnecessarily, but the goal is just to improve the understanding of the collect method. So all these components that I mention are ...
-1
votes
1
answer
151
views
How to write iterable class with sentinel to use it in find_if?
I have C++ code written around March 2023. It compiled fine back then. Now, I have to make a few changes to it, but it doesn't compile anymore. The used language standard was C++20. I don't remember ...
0
votes
0
answers
58
views
'numpy.float64' object is not iterable error when using an array
I am trying to evaluate an ARIMA model.
To evaluate the model, I want to use 5 days into the future as test data.
forecast_data = model_fit.forecast(steps=5)
# Last 5 days of forecast data
...
0
votes
1
answer
75
views
How the builtin Python's next function works as used in the Gunicorn server
The following is the code cross section from gunicorn.workers.sync.SyncWorker class self.handle method:
def handle(self, listener, client, addr):
req = None
try:
if self....
2
votes
1
answer
160
views
C++ term for an object that can be iterated through begin and end
iterator is the generic word for something that can iterate a collection of objects.
On the other hand, I'm not sure that there is a commonly accepted word in C++ for the collection itself, in ...
1
vote
0
answers
1k
views
Why do I get Uncaught TypeError: e.children is not iterable error when having 2 instances of swiper slider on the same page?
I'm trying to make 2 instances of a Swiper slider, so I can have 2 kinds of sliders on the same page. A video and a review slider.
I'm encountering a warning that says "jQuery.Deferred exception: ...
0
votes
1
answer
52
views
What happens with memory for list literals with range when converted to iterator object?
I'm wondering if CODE 2 requires 41880+ of memory space anyways, since I "created" a list... but perhaps not because I didn't store it in a variable?
In other words, are CODE 1 and CODE 2 ...
-1
votes
1
answer
62
views
Iterables difference and common elements
Given 2 iterables/lists, the goal is to extract the common and different elements from both lists.
For example, given:
x, y = [1,1,5,2,2,3,4,5,5], [2,3,4,5]
The goal is to achieve:
common = [2,3,4,5]
...
1
vote
1
answer
94
views
Enclosing an iterable in a generator expression changes the order that contexts are cleaned up
I have a Python application which has two nested with blocks, one of which occurs inside an object's __iter__ method. I have observed that wrapping the iterable object inside a generator expression ...
1
vote
1
answer
100
views
Plot iterable classes with Plotly
I'm having some problems with the plot of some iterable classes in Python. The idea is to use plotly to plot lines obtained from the iterator of a class. Here is an example of the class:
class ...
-1
votes
1
answer
36
views
Accessing maximum or minimum nested list element [duplicate]
a = [['a', 20], ['b', 36], ['c', 1], ['d', 8], ['e', 55]]
How can I print out the minimum value or maximum value by using Python built-in functions like min() or max()?
The result would look like ['e'...
-2
votes
1
answer
168
views
TypeError: 'int' object is not iterable (map(str, result))
TypeError Traceback (most recent call last)
<ipython-input-10-6eada5f638a8> in <cell line: 8>()
15 result = oddNumbers(l, r)
16
---> 17 ...
2
votes
1
answer
1k
views
How can I determine if an Iterable will be empty or not after iterating in TypeScript?
How can I differentiate between iterables that become empty after iteration and those that don't, in TypeScript?
type ReusableIterable<T> = Iterable<T> // ?
function iterate(iterable: ...
-2
votes
1
answer
394
views
I am trying to make a web-application using streamlit and getting error argument of type 'method' is not iterable
So I made a function which i later imported to another file no i am trying to make a web application using stream lit where I want user to upload a data and that data should go through my function and ...
-1
votes
1
answer
101
views
How does zip and zip_longest work with iterables in python 3.x?
This is my code snippet
from itertools import zip_longest
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
args = [iter(list1)] * 4
zipped = zip_longest(*args, fillvalue=None)
for j in ...
0
votes
4
answers
547
views
Adding items from one list to another list of lists
Suppose I have the following lists:
list_1 = [[1,2],[3,4],[5,6],[7,8]]
list_2 = [11,12,13,14]
How can I add items from the second list to each of the items from the first one?
Stated clearly, this is ...
0
votes
3
answers
544
views
How to make iterable class method?
It's telling me "TypeError: Foo.my_method(...) is not a function or its return value is not async iterable". How to make it so?
class Foo {
constructor() {
return (async () => { ...
1
vote
1
answer
1k
views
efficient way to convert iterable to list of entity
Whats an efficient way to convert iterable to list of entity?
in below code. last line which collects to list - take ~70seconds for large data set (about 400k)
//mongoDB: reading from collection
...
2
votes
3
answers
240
views
How to map a JavaScript iterable without writing an iteration function?
Some methods in Javascript, for example Map.prototype.values, return an iterable. Without writing a function to iterate through the values, can I map them to something else as per Array.prototype.map?...