Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77191
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.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.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'debug': 0.07; 'string': 0.09; 'item,': 0.09; 'lawrence': 0.09; 'sake': 0.09; 'seemed': 0.09; 'strings.': 0.09; 'style.': 0.09; 'subject:string': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'times,': 0.14; 'brothers': 0.16; 'default),': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'readable': 0.16; 'separator.': 0.16; 'threshold': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; 'thu,': 0.19; '(in': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'recognize': 0.24; 'visible': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'generally': 0.29; "doesn't": 0.30; 'change,': 0.30; 'compared': 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'context,': 0.31; 'quite': 0.32; 'reader': 0.33; 'maybe': 0.34; 'could': 0.34; 'info': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'joined': 0.36; 'two': 0.37; 'list': 0.37; 'level': 0.37; 'performance': 0.37; 'problems': 0.38; 'pm,': 0.38; 'that,': 0.38; 'short': 0.38; 'highest': 0.39; 'quote': 0.39; 'even': 0.60; 'tell': 0.60; 'numbers': 0.61; 'matter': 0.61; "you're": 0.61; 'kind': 0.63; 'real': 0.63; 'more': 0.64; 'advantages': 0.68; 'readers': 0.68; 'fact,': 0.69; 'life.': 0.83; 'complexity': 0.84; 'penalty': 0.84; 'peter,': 0.84; 'url:master': 0.84; '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; bh=wNERXeJgWNOSydxFEWKtWLnjAYyuKTLEFTfTgpBMAdI=; b=w4BQVgkPcVWemf4QYjJAXDFknrZ2osVy7aIQw1N0Apg/nzvFBb1fUNHdXUB+ZaL1WK qFZRyk3zo8HZ/8ETTFSRo8Q8VPtsr/wVGDbRX2jTLg5U6oyJPgabgFERT5H35zCJz3gY w3x/X//0XlBR7zPYWXOP0RZHyKYpPibZhErpuCntGQWm+7y2mkPTrmF1bNsF8jn/sKz2 R3KCWaJK6JAgSTUvr1TDoQKQaDkkJWx1Tx4FrLX4f7CCTZBijJ1/aAKjD+ZsUEzRMcka jgeVPvW3fYWdGujtXVgYxvFcCRqwZgVPgtLqXGm8ZxiGrk0TLKNFdfxwhUVJD4v6mKJa BGeQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.176.202 with SMTP id ck10mr36528763igc.2.1409216295384; Thu, 28 Aug 2014 01:58:15 -0700 (PDT) |
| In-Reply-To | <ltmq2t$sao$1@ger.gmane.org> |
| References | <55bab2a0-e0bc-4398-90b4-c9937498f5d8@googlegroups.com> <63bdccb4-9e34-4e40-b07d-14342e21815f@googlegroups.com> <ltmq2t$sao$1@ger.gmane.org> |
| Date | Thu, 28 Aug 2014 18:58:15 +1000 |
| Subject | Re: python string, best way to concat |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.13547.1409216298.18130.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1409216298 news.xs4all.nl 2945 [2001:888:2000:d::a6]:42840 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77191 |
Show key headers only | View raw
On Thu, Aug 28, 2014 at 6:43 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> On 28/08/2014 09:30, peter wrote:
>>
>> I used to struggle with the concept of ''.join(('hello ','world')) - it
>> seemed so convoluted compared with the intuitive 'hello '+'world', and I
>> could never remember the syntax. Also, for the strings I was generally
>> using the performance penalty was infinitesimal, so I was just adding
>> complexity for the sake of the abstract concept of a more 'pythonic' style.
>>
>> Obviously this isn't going to change, but for concatenating short strings
>> a and b is there any practical reason to avoid a+b?
>>
>> Peter
>>
>
> Please quote context, there's some smart people on this list but none of
> them are mind readers :)
Speak for yourself! I play a mind reader on Threshold RPG (in fact,
one of the highest level psions on the game), and several of my
brothers tell me I can pull the same tricks in real life. Or maybe I'm
just really good at knowing what problems they're having, even before
they recognize the problems themselves...
But Peter, no - no reason to avoid it for concatenating two strings.
The advantages of join() are visible when you have huge numbers of
strings; plus it's more readable than repeating a separator lots of
times, especially if you're working with variable numbers of list
elements:
https://github.com/Rosuav/runningtime/blob/master/runningtime.py#L211
The debug info is collected in a list (appending each item, and quite
a few of them are elided if they're some kind of default), and then
they're joined with ', ' as the separator. I could use string
appending for that, but there's no point; it's more readable this way.
Performance doesn't matter at all here, just readability.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
python string, best way to concat dennisearlevans@gmail.com - 2014-08-27 13:31 -0700
Re: python string, best way to concat Dan Stromberg <drsalists@gmail.com> - 2014-08-27 15:30 -0700
Re: python string, best way to concat Peter Otten <__peter__@web.de> - 2014-08-28 00:34 +0200
Re: python string, best way to concat MRAB <python@mrabarnett.plus.com> - 2014-08-27 23:42 +0100
Re: python string, best way to concat Tim Chase <python.list@tim.thechases.com> - 2014-08-27 17:44 -0500
Re: python string, best way to concat Chris Angelico <rosuav@gmail.com> - 2014-08-28 08:55 +1000
Re: python string, best way to concat Peter Otten <__peter__@web.de> - 2014-08-28 00:59 +0200
Re: python string, best way to concat MRAB <python@mrabarnett.plus.com> - 2014-08-28 08:12 +0100
Re: python string, best way to concat peter <peter.mosley@talk21.com> - 2014-08-28 01:30 -0700
Re: python string, best way to concat Marko Rauhamaa <marko@pacujo.net> - 2014-08-28 11:34 +0300
Re: python string, best way to concat Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-28 09:43 +0100
Re: python string, best way to concat Chris Angelico <rosuav@gmail.com> - 2014-08-28 18:58 +1000
Re: python string, best way to concat Roy Smith <roy@panix.com> - 2014-08-28 08:08 -0400
Re: python string, best way to concat Mihamina Rakotomandimby <mihamina.rakotomandimby@rktmb.org> - 2014-08-28 15:19 +0300
Re: python string, best way to concat Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-28 15:48 +0100
csiph-web