[Python-ideas] Enable subscription operator for generator expressions

2020-11-17 Thread Nuri Jung
How about enabling subscription operator (`[]`) for generator expressions? Also for all `zip()`, `key()`, etc. They could be evaluated in the background only for the requested amount, to avoid evaluating the whole expression to something like a list or tuple, then indexed.

[Python-ideas] Re: Enable subscription operator for generator expressions

2020-11-17 Thread Nuri Jung
I agree with your detailed explanation, and it would be a great idea to add a keyword argument to the `next()` function. Just for reference, I believe C++ also has similar function, `std::next()` which advances 'iterators', and it also works on non-indexible (i.e. linked list, etc.)

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Nuri Jung
So, what is the conclusion? I also think reversed(enumerate(some_seq)) will be very useful in many cases. It should: 1) work the same as reversed(tuple(enumerate(...))) for "reversible" objects as argument of enumerate, 2) raise TypeError if the object is not reversible. Or, another option