Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:57 AM, Chris Angelico wrote: def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::][::-1] if len(L)==0: done=True Why not just "while L"? OK, here it is with Chris' excellent adv

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:57 AM, Chris Angelico wrote: On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris wrote: Consider this generator variation: def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::][::-1]

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/12/14 11:55 AM, Marko Rauhamaa wrote: while not done: Better Python and not bad English, either. ... and taking Marko's good advice, what I think you really wanted: >>> def poplist(L): done = False while not done: yield L[::-1][:1:] L

Re: About python while statement and pop()

2014-06-12 Thread Marko Rauhamaa
> while done==False: Correction: while not done: Better Python and not bad English, either. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: About python while statement and pop()

2014-06-12 Thread Chris Angelico
On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris wrote: > Consider this generator variation: > def poplist(L): > done = False > while done==False: > > yield L[::-1][:1:] > L = L[::-1][1::][::-1] > if len(L)==0: done=True Why not j

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/11/14 10:12 PM, hito koto wrote: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y Consider this generator variation: >>> def poplist(L): done = False while done==False: yield L[::-1][:1:] L = L[::-1][1::]

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris
On 6/11/14 10:12 PM, hito koto wrote: i want to change this is code: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y Consider this generator (all kinds of permutations on the idea): >>> L1 [1, 2, 3, 4, 5, 6, 7] >>> def poplist(L): while True:

Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > def foo(x): > > > ... y = [] > > > ... while x !=[]: > > > ... y.append(x.pop()) > > > ...

Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > def foo(x): > > > ... y = [] > > > ... while x !=[]: > > > ... y.append(x.pop()) > > > ...

Re: About python while statement and pop()

2014-06-11 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano: > On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > > > > > I want to use while statement, > > > > > > for example: > > def foo(x): > > > ... y = [] > > > ... while x !=[]: > > > ... y.append(x.pop()) > > > ...

Re: About python while statement and pop()

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote: > I want to use while statement, > > for example: def foo(x): > ... y = [] > ... while x !=[]: > ... y.append(x.pop()) > ... return y > ... print foo(a) > [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]] a > [] but thi

Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 2:56 PM, hito koto wrote: > I want to use while statement, This sounds like homework. Go back to your teacher/tutor for assistance, rather than asking us to do the work for you; or at very least, word your question in such a way that we can help you to learn, rather than j

Re: About python while statement and pop()

2014-06-11 Thread hito koto
2014年6月12日木曜日 12時58分27秒 UTC+9 Chris Angelico: > On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre > > wrote: > > > Le 12/06/2014 05:12, hito koto a écrit : > > > > > >> Hello,all > > >> I'm first time, > > >> > > >> I want to make a while statement which can function the same x.pop () an

Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre wrote: > Le 12/06/2014 05:12, hito koto a écrit : > >> Hello,all >> I'm first time, >> >> I want to make a while statement which can function the same x.pop () and >> without the use of pop、how can i to do? >> >> i want to change this is code: >

Re: About python while statement and pop()

2014-06-11 Thread Vincent Vande Vyvre
Le 12/06/2014 05:12, hito koto a écrit : Hello,all I'm first time, I want to make a while statement which can function the same x.pop () and without the use of pop、how can i to do? i want to change this is code: def foo(x): y = [] while x !=[]: y.append(x.pop()) return

About python while statement and pop()

2014-06-11 Thread hito koto
Hello,all I'm first time, I want to make a while statement which can function the same x.pop () and without the use of pop、how can i to do? i want to change this is code: def foo(x): y = [] while x !=[]: y.append(x.pop()) return y -- https://mail.python.org/mailman/listinfo