Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73220
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Mark H Harris <harrismh777@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: About python while statement and pop() |
| Date | Thu, 12 Jun 2014 11:41:24 -0500 |
| Organization | Aioe.org NNTP Server |
| Lines | 43 |
| Message-ID | <lncl7g$ni6$1@speranza.aioe.org> (permalink) |
| References | <8d6207ab-b883-4940-8e53-75546a91d4dd@googlegroups.com> |
| NNTP-Posting-Host | eSF12mcVRIwL+eMIMJ03mA.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com comp.lang.python:73220 |
Show key headers only | View raw
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: yield L[::-1][:1:] L = L[::-1][1::][::-1] >>> pop = poplist(L1) >>> next(pop) [7] >>> next(pop) [6] >>> next(pop) [5] >>> next(pop) [4] >>> next(pop) [3] >>> next(pop) [2] >>> next(pop) [1] >>> next(pop) [] >>> next(pop) []
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
About python while statement and pop() hito koto <hitokoto2014@gmail.com> - 2014-06-11 20:12 -0700
Re:About python while statement and pop() Dave Angel <davea@davea.name> - 2014-06-11 22:34 -0500
Re: About python while statement and pop() Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2014-06-12 05:40 +0200
Re: About python while statement and pop() Chris Angelico <rosuav@gmail.com> - 2014-06-12 13:58 +1000
Re: About python while statement and pop() hito koto <hitokoto2014@gmail.com> - 2014-06-11 21:56 -0700
Re: About python while statement and pop() Chris Angelico <rosuav@gmail.com> - 2014-06-12 15:08 +1000
Re: About python while statement and pop() Steven D'Aprano <steve@pearwood.info> - 2014-06-12 05:43 +0000
Re: About python while statement and pop() hito koto <hitokoto2014@gmail.com> - 2014-06-11 23:06 -0700
Re: About python while statement and pop() hito koto <hitokoto2014@gmail.com> - 2014-06-12 00:13 -0700
Re: About python while statement and pop() hito koto <hitokoto2014@gmail.com> - 2014-06-12 02:51 -0700
Re: About python while statement and pop() Mark H Harris <harrismh777@gmail.com> - 2014-06-12 11:41 -0500
Re: About python while statement and pop() Mark H Harris <harrismh777@gmail.com> - 2014-06-12 11:49 -0500
Re: About python while statement and pop() Marko Rauhamaa <marko@pacujo.net> - 2014-06-12 19:55 +0300
Re: About python while statement and pop() Mark H Harris <harrismh777@gmail.com> - 2014-06-12 12:07 -0500
Re: About python while statement and pop() Chris Angelico <rosuav@gmail.com> - 2014-06-13 02:57 +1000
Re: About python while statement and pop() Mark H Harris <harrismh777@gmail.com> - 2014-06-12 12:10 -0500
Re: About python while statement and pop() Mark H Harris <harrismh777@gmail.com> - 2014-06-12 12:16 -0500
Re: About python while statement and pop() wxjmfauth@gmail.com - 2014-06-12 11:37 -0700
csiph-web