Yupee.. Thanks for the knowledge sharing.
Regards
Prahallad
On Sat, 16 Feb 2019, 12:18 dieter Prahallad Achar writes:
>
> > I get list object instead gen obj
>
> If you have a list "l" and want a generator, you can use
>( x for x in l)
> or simpler "iter(l)" - which gives you an interator
riations on the above that do not alter the list
> would be to use an index based on the length of the list and count backward
> as you return what is at that index.
>
> -Original Message-
> From: Python-list On
> Behalf Of dieter
> Sent: Saturday, February 16, 2019 1:47
x.
-Original Message-
From: Python-list On
Behalf Of dieter
Sent: Saturday, February 16, 2019 1:47 AM
To: python-list@python.org
Subject: Re: Problem : Generator
Prahallad Achar writes:
> I get list object instead gen obj
If you have a list "l" and want a generator, yo
Prahallad Achar writes:
> I get list object instead gen obj
If you have a list "l" and want a generator, you can use
( x for x in l)
or simpler "iter(l)" - which gives you an interator over "l".
An "iterator" is slightly more general than a generator
(every generator is also an iterator).
Prahallad Achar於 2019年2月15日星期五 UTC+8下午5時27分36秒寫道:
> I get list object instead gen obj
>
> On Fri, 15 Feb 2019, 13:57 Chris Angelico
> > On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar
> > wrote:
> > >
> > > How about this
> > > List1=[ 1,2,3,4]
> > > Rever_gen = ( x*x for x in list1, reversed
I get list object instead gen obj
On Fri, 15 Feb 2019, 13:57 Chris Angelico On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar
> wrote:
> >
> > How about this
> > List1=[ 1,2,3,4]
> > Rever_gen = ( x*x for x in list1, reversed = True)
> >
> > Rever_gen gets generator object and iterating it now ge
On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar wrote:
>
> How about this
> List1=[ 1,2,3,4]
> Rever_gen = ( x*x for x in list1, reversed = True)
>
> Rever_gen gets generator object and iterating it now gets reverse order..
>
> Am I correct here? Suggest me
>
How about reversed(list1) ?
ChrisA
-
How about this
List1=[ 1,2,3,4]
Rever_gen = ( x*x for x in list1, reversed = True)
Rever_gen gets generator object and iterating it now gets reverse order..
Am I correct here? Suggest me
On Fri, 15 Feb 2019, 12:33 dieter Prahallad Achar writes:
> > How to implement reverse generator
>
> A gene
Prahallad Achar writes:
> How to implement reverse generator
A generator generates a sequence of values.
The notion "reverse generator" suggests that you have a sequence
of values and want to produce it in reverse order.
This is not always possible.
Consider:
def natural():
i = 0
while True
Prahallad Achar writes:
> How to implement reverse generator
Welcome to the Python forum!
That sounds like an interesting problem. Can you describe it more
precisely? What should a “reverse generator” actually do (and not do)?
Ideally, give an example:
* Some code you would maybe expect to cr
How to implement reverse generator
It is only passing data in reverse or how it is
Yeild always returns next value and is question valid?
Thanks and Regards
Prahallad
--
https://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo