Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77213
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin.stu.neva.ru!newsfeed3.funet.fi!newsfeeds.funet.fi!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'string': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sake': 0.09; 'seemed': 0.09; 'style.': 0.09; 'subject:string': 0.09; 'url:activestate': 0.09; 'language.': 0.14; "%s'": 0.16; "'%s": 0.16; 'delimiter': 0.16; 'fine.': 0.16; 'iterable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'string:': 0.16; 'syntax,': 0.16; 'subject:python': 0.16; 'language': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; 'written': 0.21; '(in': 0.22; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'generally': 0.29; 'url:code': 0.29; "doesn't": 0.30; 'change,': 0.30; 'compared': 0.30; 'moved': 0.30; 'said,': 0.30; "skip:' 10": 0.31; 'probably': 0.32; '(e.g.': 0.33; 'could': 0.34; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'doing': 0.36; 'two': 0.37; 'list': 0.37; 'performance': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'first': 0.61; 'you.': 0.62; 'our': 0.64; 'pick': 0.64; 'places': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'smith': 0.68; 'article': 0.77; 'as:': 0.81; 'complexity': 0.84; 'penalty': 0.84; 'received:89': 0.85 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: python string, best way to concat |
| Date | Thu, 28 Aug 2014 15:48:48 +0100 |
| References | <55bab2a0-e0bc-4398-90b4-c9937498f5d8@googlegroups.com> <63bdccb4-9e34-4e40-b07d-14342e21815f@googlegroups.com> <roy-87A30C.08075228082014@news.panix.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-89-240-167-224.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
| In-Reply-To | <roy-87A30C.08075228082014@news.panix.com> |
| 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.13564.1409237343.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1409237343 news.xs4all.nl 2897 [2001:888:2000:d::a6]:52373 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77213 |
Show key headers only | View raw
On 28/08/2014 13:08, Roy Smith wrote:
> In article <63bdccb4-9e34-4e40-b07d-14342e21815f@googlegroups.com>,
> peter <peter.mosley@talk21.com> 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?
>
> For places where performance doesn't matter, string addition is just
> fine. The computer works for you. If you're working for the computer,
> you're doing something wrong.
>
> That being said, join is typically used where you have a variable number
> of strings in some iterable (e.g. a list of strings). For exactly two
> strings, I would have probably written this as:
>
> '%s %s' % (string1, string2)
>
> and if I really wanted to use the join syntax, I would have moved the
> delimiter (in this case, a space), into the first string:
>
> ' '.join([string1, string2])
>
> Be aware of the various ways, then pick the one that works for you.
>
Which reminds me of
http://code.activestate.com/recipes/577845-format_iter-easy-formatting-of-arbitrary-iterables/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous 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