Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73199
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.043 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'subject:()': 0.09; 'subject:while': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'be:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'reversed': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'subject:About': 0.31; 'though.': 0.31; 'probably': 0.32; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'changing': 0.37; 'list': 0.37; 'pm,': 0.38; '12,': 0.39; 'new': 0.61; 'simply': 0.61; 'first': 0.61; 'for:': 0.64; 'more': 0.64; 'reverse': 0.68; 'yours': 0.88; 'thing,': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=gfqYuuKyKbCRJw8RFDc3GPt2ZHUOHqjQUln81c4LMkk=; b=fQuFeSnUjC7dYW0rQzg030YsIQS06cSmi1O1G0fpeFLtVxGIirslFh6+luav28kj4W w0zGBCEGOmleWQIpOSfDnrrsoYW/ed8NnC8TXnRTWKNpCviMAfkPA09NFLK75CuiYktX 7fTF2lmNv0UPWDICDzxo1m5qqhBZFwFDmzfGz7gknz7b34nDm8hsB+cQ9raLoC4o+eFW ObBhhKkyHkiLJhHlpWOUIYPP13VbACrbfYKyjlyKt/JvqQClaGraF0TC9WmjFjbVv+KE 3sz2u4qfmqFCX+VUn4GGiyaVOuYkk7RNP2xyjr4hjjBxRDYGa9p9F3X+BD9qgdKy6ri7 oCDQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.244.84 with SMTP id xe20mr6279453vdc.3.1402545507184; Wed, 11 Jun 2014 20:58:27 -0700 (PDT) |
| In-Reply-To | <53992114.3040006@swing.be> |
| References | <8d6207ab-b883-4940-8e53-75546a91d4dd@googlegroups.com> <53992114.3040006@swing.be> |
| Date | Thu, 12 Jun 2014 13:58:27 +1000 |
| Subject | Re: About python while statement and pop() |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11026.1402545515.18130.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402545515 news.xs4all.nl 2885 [2001:888:2000:d::a6]:37360 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73199 |
Show key headers only | View raw
On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre
<vincent.vandevyvre@swing.be> 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:
>>
>> def foo(x):
>> y = []
>> while x !=[]:
>> y.append(x.pop())
>> return y
>
> Something like that :
>
> def foo(x):
> return reversed(x)
That doesn't do the same thing, though. Given a list x, the original
function will empty that list and return a new list in reverse order,
but yours will return a reversed iterator over the original list
without changing it. This is more accurate, but still not identical,
and probably not what the OP's teacher is looking for:
def foo(x):
y = x[::-1]
x[:] = []
return y
If the mutation of x is unimportant, it can simply be:
def foo(x):
return x[::-1]
ChrisA
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