Il 20/12/2020 21:00, danilob ha scritto:
Hi,
I'm an absolute beginner in Python (and in English too ;-)
Running this code:
--
# Python 3.9.0
a = [[1, 2, 0, 3, 0],
[0, 4, 5, 0, 6],
[7, 0, 8, 0, 9],
[2, 3, 0, 0, 1],
[0, 0, 1, 8, 0]]
b = ((x[0] for x in a))
you stop asking.
>
> This is just a thought, not a request for such a feature.
>
> -Original Message-
> From: Python-list On
> Behalf Of ast
> Sent: Saturday, January 23, 2021 2:54 AM
> To: python-list@python.org
> Subject: Re: list() strange behaviour
>
>
On Sun, Jan 24, 2021 at 8:49 AM Cameron Simpson wrote:
>
> On 23Jan2021 12:20, Avi Gross wrote:
> >I am wondering how hard it would be to let some generators be resettable?
> >
> >I mean if you have a generator with initial conditions that change as it
> >progresses, could it cache away those ini
On 23Jan2021 12:20, Avi Gross wrote:
>I am wondering how hard it would be to let some generators be resettable?
>
>I mean if you have a generator with initial conditions that change as it
>progresses, could it cache away those initial conditions and upon some
>signal, simply reset them? Objects of
Of ast
Sent: Saturday, January 23, 2021 2:54 AM
To: python-list@python.org
Subject: Re: list() strange behaviour
Le 20/12/2020 à 21:00, danilob a écrit :
>
>
> b = ((x[0] for x in a))
>
There is a useless pair of parenthesis
b = (x[0] for x in a)
b is a GENERATOR expression
On 1/23/2021 2:54 AM, Unknown wrote:
Le 20/12/2020 à 21:00, danilob a écrit :
b = ((x[0] for x in a))
There is a useless pair of parenthesis
b = (x[0] for x in a)
b is a GENERATOR expression
first list(b) calls next method on b repetedly until b is empty.
So it provides the "content" of
Le 20/12/2020 à 21:00, danilob a écrit :
b = ((x[0] for x in a))
There is a useless pair of parenthesis
b = (x[0] for x in a)
b is a GENERATOR expression
first list(b) calls next method on b repetedly until b is empty.
So it provides the "content" of b
second list(b) provides nothing si
On 21Dec2020 08:09, Cameron Simpson wrote:
>>b = ((x[0] for x in a))
>
>This is a generator comprehension, and _not_ a list.
I should amend this: a "generator _expression_", not comprehension. A
"generator comprehension" is not a thing.
Apologies,
Cameron Simpson
--
https://mail.python.org/ma
On 20Dec2020 21:00, danilob wrote:
>I'm an absolute beginner in Python (and in English too ;-)
Well your English is far better than my very poor second language.
>Running this code:
>--
># Python 3.9.0
>
>a = [[1, 2, 0, 3, 0],
> [0, 4, 5, 0, 6],
> [7, 0, 8, 0, 9],
> [2, 3
On 2020-12-20 21:00, danilob wrote:
> b = ((x[0] for x in a))
here you create a generator
> print(list(b))
> [1, 0, 7, 2, 0]
and then you consume all the things it generates here which means
that when you go to do this a second time
> print(list(b))
the generator is already empty/exhausted so
Hi,
I'm an absolute beginner in Python (and in English too ;-)
Running this code:
--
# Python 3.9.0
a = [[1, 2, 0, 3, 0],
[0, 4, 5, 0, 6],
[7, 0, 8, 0, 9],
[2, 3, 0, 0, 1],
[0, 0, 1, 8, 0]]
b = ((x[0] for x in a))
print(list(b))
print(list(b))
---
11 matches
Mail list logo