Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91602
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.040 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'python': 0.11; '2.7.3': 0.16; 'happily': 0.16; 'iterator,': 0.16; 'result:': 0.16; 'reversed': 0.16; 'unnecessary.': 0.16; 'wrote:': 0.16; 'intermediate': 0.18; 'examples': 0.18; 'skip:" 30': 0.20; '31,': 0.22; '2015': 0.23; 'dec': 0.23; 'elements': 0.23; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.28; 'subject:use': 0.33; 'received:google.com': 0.34; 'to:addr:python- list': 0.35; 'list': 0.35; 'but': 0.36; 'list,': 0.36; 'subject:: ': 0.37; 'pm,': 0.39; 'method': 0.39; 'to:addr:python.org': 0.39; 'more': 0.62; 'construction': 0.73; 'denis': 0.84; 'to:name:python': 0.84; '2014,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=P0kvVSVRgi5cP9M/9ouV2uKaEIazH8R8O8on6/I88t4=; b=GpjCKwbZOh0jZ9JdTLFYlHIRj2r9ucnLKXyxqhhvo+riJALzW4dkkG9EpfVTCNwjo4 1TkzAwSf6kfcdmgzauwx9s7nRo7lnS6FYwgyj7INvL9cK9p1ULIVFZIgjVCbxh4X45hx M3nfHqx9d6HJdjw2GmDRNUlmjckzvQPxtAMOxqspng2JNRyMhnxOhwA9s6TC2HsrP+8Q HJk7/gBtiTfOV866myJN/AmhFxWd3u1b1Q7oE6qDcqR1S7vLpVENSY0JDgqxxTlGz22Q 7SY7cpbhy5Rv0ESMVtdi9iE1YwL4VH3maJSpf2FgkPwYv5S5Hj/xqJD29mKrXvlu+G/O NzgQ== |
| X-Received | by 10.50.36.9 with SMTP id m9mr9849180igj.15.1433117213982; Sun, 31 May 2015 17:06:53 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <mkfp4q$lkf$3@dont-email.me> |
| References | <514c05fc-dded-4278-ac86-3e8e3cd0e851@googlegroups.com> <mkfp4q$lkf$3@dont-email.me> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sun, 31 May 2015 18:06:13 -0600 |
| Subject | Re: What use for reversed()? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.254.1433121593.5151.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1433121593 news.xs4all.nl 2962 [2001:888:2000:d::a6]:46552 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91602 |
Show key headers only | View raw
On Sun, May 31, 2015 at 1:58 PM, Denis McMahon <denismfmcmahon@gmail.com> wrote:
> reversed returns an iterator, not a list, so it returns the reversed list
> of elements one at a time. You can use list() or create a list from
> reversed and then join the result:
>
> $ python
> Python 2.7.3 (default, Dec 18 2014, 19:10:20)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> "".join(list(reversed("fred")))
> 'derf'
>>>> "".join([x for x in reversed("fred")])
> 'derf'
>
> So reversed can do it, but needs a little help
The str.join method will happily accept an iterator, so the
intermediate list construction in those examples is unnecessary.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 12:40 -0700
Re: What use for reversed()? Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-31 19:58 +0000
Re: What use for reversed()? Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-31 18:06 -0600
Re: What use for reversed()? cheshire <supportNOSPAM@microsoft.com> - 2015-05-31 23:26 +0200
Re: What use for reversed()? Tim Delaney <timothy.c.delaney@gmail.com> - 2015-06-01 09:23 +1000
Re: What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 20:11 -0700
Re: What use for reversed()? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-01 01:30 +0100
Re: What use for reversed()? Tim Delaney <timothy.c.delaney@gmail.com> - 2015-06-01 13:59 +1000
Re: What use for reversed()? fl <rxjwg98@gmail.com> - 2015-05-31 22:15 -0700
Re: What use for reversed()? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-06-01 09:11 +0300
csiph-web