Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9100

Re: String concatenation vs. string formatting

Date 2011-07-08 18:29 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
Subject Re: String concatenation vs. string formatting
References <mailman.785.1310156331.1164.python-list@python.org> <877h7sidjq.fsf@benfinney.id.au>
Newsgroups comp.lang.python
Message-ID <mailman.789.1310167795.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 2011.07.08 05:59 PM, Ben Finney wrote:
> With the caveat that the formatting of that line should be using PEP 8
> indentation for clarity:
PEP 8 isn't bad, but I don't agree with everything in it. Certain lines
look good in chunks, some don't, at least to me. It's quite likely I'm
going to be writing 98%, if not more, of this project's code, so what
looks good to me matters more than a standard (as long as the code
works). Obviously, if I need to work in a team, then things change.
> > and when a variable is used a bunch of times, concatenation is fine,
I prefaced that sentence with "Other than the case", as in "except for
the following case(s)".
> There is often more than one way to do it. The Zen of Python is explicit
> that there should be one obvious way to do it (and preferably only one).
I meant in contrast to the idea of intentionally having multiple ways to
do something, all with roughly equal merit.



On 2011.07.08 04:38 PM, Ian Kelly wrote:
> Also, string formatting (especially using the new syntax like you are)
> is much clearer because there's less noise (the quotes all over the
> place and the plusses)
I don't find it that much clearer unless there are a lot of chunks.
> and it's better for dealing with internationalization if you need to
> do that.
I hadn't thought of that. That's probably the best reason to use string
formatting.


Thanks, everyone.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

String concatenation vs. string formatting Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-08 15:18 -0500
  Re: String concatenation vs. string formatting John Gordon <gordon@panix.com> - 2011-07-08 20:23 +0000
    Re: String concatenation vs. string formatting Ben Finney <ben+python@benfinney.id.au> - 2011-07-09 08:50 +1000
      Re: String concatenation vs. string formatting Ben Finney <ben+python@benfinney.id.au> - 2011-07-09 09:15 +1000
    Re: String concatenation vs. string formatting Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-09 06:23 +0200
    Re: String concatenation vs. string formatting Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-10 01:45 -0500
      Re: String concatenation vs. string formatting Ben Finney <ben+python@benfinney.id.au> - 2011-07-10 17:07 +1000
      Re: String concatenation vs. string formatting Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-10 23:42 +1000
      Re: String concatenation vs. string formatting Roy Smith <roy@panix.com> - 2011-07-10 10:33 -0400
        Re: String concatenation vs. string formatting Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-11 08:48 +1000
        Re: String concatenation vs. string formatting Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-10 18:24 -0500
  Re: String concatenation vs. string formatting Billy Mays <noway@nohow.com> - 2011-07-08 16:57 -0400
    Re: String concatenation vs. string formatting Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-09 15:30 +1000
      Re: String concatenation vs. string formatting Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-09 00:04 -0600
      Re: String concatenation vs. string formatting Chris Angelico <rosuav@gmail.com> - 2011-07-09 16:16 +1000
      Re: String concatenation vs. string formatting Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-09 00:29 -0600
  Re: String concatenation vs. string formatting Ben Finney <ben+python@benfinney.id.au> - 2011-07-09 08:59 +1000
    Re: String concatenation vs. string formatting Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-08 18:29 -0500
  Re: String concatenation vs. string formatting Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-09 15:12 +1000

csiph-web