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


Groups > comp.lang.python > #108397 > unrolled thread

Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

Started byDFS <nospam@dfs.com>
First post2016-05-08 19:10 -0400
Last post2016-05-12 18:40 +1000
Articles 20 on this page of 59 — 22 participants

Back to article view | Back to comp.lang.python


Contents

  Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-08 19:10 -0400
    Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Tim Chase <python.list@tim.thechases.com> - 2016-05-08 18:37 -0500
    Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Joel Goldstick <joel.goldstick@gmail.com> - 2016-05-08 20:02 -0400
    String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-09 02:44 +0200
      Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) Chris Angelico <rosuav@gmail.com> - 2016-05-09 12:16 +1000
        Re: String concatenation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-09 23:21 +0200
          Re: String concatenation Steven D'Aprano <steve@pearwood.info> - 2016-05-10 12:32 +1000
            Re: String concatenation Chris Angelico <rosuav@gmail.com> - 2016-05-10 12:42 +1000
              Re: String concatenation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-12 17:43 +1000
          Re: String concatenation Rustom Mody <rustompmody@gmail.com> - 2016-05-09 20:45 -0700
            Re: String concatenation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-10 16:46 +1000
              Re: String concatenation Paul Rubin <no.email@nospam.invalid> - 2016-05-10 00:13 -0700
                Re: String concatenation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-10 17:54 +1000
                  Re: String concatenation David Palao <dpalao.python@gmail.com> - 2016-05-10 10:15 +0200
                    Re: String concatenation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-12 17:27 +1000
      Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) srinivas devaki <mr.eightnoteight@gmail.com> - 2016-05-09 09:01 +0530
      Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) srinivas devaki <mr.eightnoteight@gmail.com> - 2016-05-09 09:13 +0530
      Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) Michael Selik <michael.selik@gmail.com> - 2016-05-09 18:29 +0000
      Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 19:53 -0400
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-11 02:16 +0200
          Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 20:33 -0400
          Moderation [was Re: ...What's wrong with this concatenation statement?] Steven D'Aprano <steve@pearwood.info> - 2016-05-11 11:17 +1000
          Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-11 11:43 +1000
            Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-11 21:12 +0200
          Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Ned Batchelder <ned@nedbatchelder.com> - 2016-05-11 12:39 -0700
            Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-12 09:07 +1000
            Re: % formatting vs .format() (was: What's wrong with this concatenation statement?) Tim Chase <python.list@tim.thechases.com> - 2016-05-11 18:31 -0500
      Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) sohcahtoa82@gmail.com - 2016-05-10 17:38 -0700
        Re: String concatenation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-11 21:14 +0200
          Re: String concatenation sohcahtoa82@gmail.com - 2016-05-11 14:30 -0700
            Re: String concatenation Ned Batchelder <ned@nedbatchelder.com> - 2016-05-11 14:50 -0700
            Re: String concatenation DFS <nospam@dfs.com> - 2016-05-11 18:25 -0400
    Re: What's wrong with this concatenation statement? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-09 17:53 +1000
      Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 12:16 -0400
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Rustom Mody <rustompmody@gmail.com> - 2016-05-10 09:41 -0700
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Stephen Hansen <me+python@ixokai.io> - 2016-05-10 09:42 -0700
          Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 18:37 -0400
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Steven D'Aprano <steve@pearwood.info> - 2016-05-11 02:44 +1000
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-10 12:15 -0600
          Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 17:21 -0400
            Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-11 07:27 +1000
              Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 19:40 -0400
                Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Paul Rubin <no.email@nospam.invalid> - 2016-05-10 19:14 -0700
                Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? alister <alister.ware@ntlworld.com> - 2016-05-12 09:12 +0000
                  Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-12 19:23 +1000
                    Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-12 08:24 -0400
                  Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Michael Torrie <torriem@gmail.com> - 2016-05-12 08:39 -0600
                  Why online forums have bad behaviour (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) Ben Finney <ben+python@benfinney.id.au> - 2016-05-13 05:36 +1000
                  Re: Why online forums have bad behaviour (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) Jason Friedman <jsf80238@gmail.com> - 2016-05-12 21:05 -0600
            Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Ethan Furman <ethan@stoneleaf.us> - 2016-05-10 15:12 -0700
              Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 19:29 -0400
                Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-12 13:39 +0000
                  Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-12 23:50 +1000
            Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Ethan Furman <ethan@stoneleaf.us> - 2016-05-10 16:16 -0700
              Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? DFS <nospam@dfs.com> - 2016-05-10 19:41 -0400
    Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? srinivas devaki <mr.eightnoteight@gmail.com> - 2016-05-12 13:53 +0530
      Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Ned Batchelder <ned@nedbatchelder.com> - 2016-05-12 02:36 -0700
        Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Steven D'Aprano <steve@pearwood.info> - 2016-05-13 01:06 +1000
    Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Chris Angelico <rosuav@gmail.com> - 2016-05-12 18:40 +1000

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#108506

FromDFS <nospam@dfs.com>
Date2016-05-10 20:33 -0400
Message-ID<ngtudp$u6c$1@dont-email.me>
In reply to#108505
On 5/10/2016 8:16 PM, Thomas 'PointedEars' Lahn wrote:
> DFS wrote:
>
>> On 5/8/2016 8:44 PM, Thomas 'PointedEars' Lahn wrote:
>>> DFS wrote:
>>>> sSQL =  "line 1\n"
>>>> sSQL += "line 2\n"
>>>> sSQL += "line 3"
>>>
>>> […]
>>> #-----------------------------------------------------------------------
>>> sSQL = ("line 1\n"
>>>         "line 2\n"
>>>         "line 3")
>>> #-----------------------------------------------------------------------
>>>
>>> […]
>>
>> or
>>
>> sSQL = "line 1\n" \
>>           "line 2\n" \
>>           "line 3"
>>
>
> Parentheses are less error-prone.
>
>>> With the “%” string operator (deprecated),
>>
>> according to who?
>
> TFM.

What FM are you talking about?



>>> Next time, RTFM first:
>>
>>
>> Ironically, PointyHead, […]
>>
>>> Internet is the thing with cables; Usenet is the thing with people.  I
>>> for one tend to avoid communicating with few-letter entities; exceptions
>>> to that would probably include only E.T., M.J., ALF, and K.I.T.T.
>>
>> How about FU?
>
> *PLONK*
>
> (Note to moderators: But you have let *this* through, huh?)

It was a /joke/, fella.  Funny, too.

Chill.





[toc] | [prev] | [next] | [standalone]


#108509 — Moderation [was Re: ...What's wrong with this concatenation statement?]

FromSteven D'Aprano <steve@pearwood.info>
Date2016-05-11 11:17 +1000
SubjectModeration [was Re: ...What's wrong with this concatenation statement?]
Message-ID<57328837$0$22142$c3e8da3$5496439d@news.astraweb.com>
In reply to#108505
On Wed, 11 May 2016 10:16 am, Thomas 'PointedEars' Lahn wrote:

> (Note to moderators: But you have let *this* through, huh?)


Moderation only affects the mailing list python-list@python.org, the Usenet
mirror remains unmoderated. If you are reading this via Usenet, you may see
DFS's insults, but it doesn't appear here:

https://mail.python.org/pipermail/python-list/2016-May/thread.html


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#108510

FromChris Angelico <rosuav@gmail.com>
Date2016-05-11 11:43 +1000
Message-ID<mailman.584.1462931032.32212.python-list@python.org>
In reply to#108505
On Wed, May 11, 2016 at 10:16 AM, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:
>>> With the “%” string operator (deprecated),
>>
>> according to who?
>
> TFM.

[citation needed]

ChrisA

[toc] | [prev] | [next] | [standalone]


#108529

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-05-11 21:12 +0200
Message-ID<4987209.zhW7KP61WV@PointedEars.de>
In reply to#108510
Chris Angelico wrote:

> On Wed, May 11, 2016 at 10:16 AM, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
>>>> With the “%” string operator (deprecated),
>>> according to who?
>> TFM.
> 
> [citation needed]

BTDT.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#108531

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-05-11 12:39 -0700
Message-ID<dbb45b71-a610-4a84-9f85-a08983ff3a35@googlegroups.com>
In reply to#108505
On Tuesday, May 10, 2016 at 8:16:43 PM UTC-4, Thomas 'PointedEars' Lahn wrote:
> DFS wrote:
> 
> > On 5/8/2016 8:44 PM, Thomas 'PointedEars' Lahn wrote:
> >> With the “%” string operator (deprecated),
> > 
> > according to who?
> 
> TFM.
> 

It's easy to be confused on this point.  Early on in the 3.x planning,
there was talk of deprecating %-formatting.  It didn't happen, though.

The docs have discussed it in a few different ways over the years.

Python 3.0 and 3.1 said:

    https://docs.python.org/3.1/library/stdtypes.html#old-string-formatting-operations

    Note: The formatting operations described here are obsolete and
    may go away in future versions of Python. Use the new String
    Formatting in new code. 

3.2 said:

    https://docs.python.org/3.2/library/stdtypes.html#old-string-formatting-operations

    As the new String Formatting syntax is more flexible and handles
    tuples and dictionaries naturally, it is recommended for new code.
    However, there are no current plans to deprecate printf-style formatting.

3.3 and up say:

    https://docs.python.org/3.3/library/stdtypes.html#printf-style-string-formatting

    Note: The formatting operations described here exhibit a variety of
    quirks that lead to a number of common errors (such as failing to
    display tuples and dictionaries correctly).  Using the newer str.format()
    interface helps avoid these errors, and also provides a generally more
    powerful, flexible and extensible approach to formatting text.

So yes, .format is newer and more powerful, and there are good reasons to
recommend it.  But %-formatting is not deprecated.

--NMB.

[toc] | [prev] | [next] | [standalone]


#108536

FromChris Angelico <rosuav@gmail.com>
Date2016-05-12 09:07 +1000
Message-ID<mailman.600.1463008060.32212.python-list@python.org>
In reply to#108531
On Thu, May 12, 2016 at 5:39 AM, Ned Batchelder <ned@nedbatchelder.com> wrote:
> On Tuesday, May 10, 2016 at 8:16:43 PM UTC-4, Thomas 'PointedEars' Lahn wrote:
>> DFS wrote:
>>
>> > On 5/8/2016 8:44 PM, Thomas 'PointedEars' Lahn wrote:
>> >> With the “%” string operator (deprecated),
>> >
>> > according to who?
>>
>> TFM.
>>
>
> It's easy to be confused on this point.  Early on in the 3.x planning,
> there was talk of deprecating %-formatting.  It didn't happen, though.
>
> The docs have discussed it in a few different ways over the years.
>
> Python 3.0 and 3.1 said:
>
>     https://docs.python.org/3.1/library/stdtypes.html#old-string-formatting-operations
>
>     Note: The formatting operations described here are obsolete and
>     may go away in future versions of Python. Use the new String
>     Formatting in new code.
>
> 3.3 and up say:
>
>     https://docs.python.org/3.3/library/stdtypes.html#printf-style-string-formatting

Note also the change in the link: the current docs don't even call it
"old string formatting" any more; the two are perfectly parallel. But
at no point was percent formatting EVER deprecated, which is a very
specific technical term. As you say, there was talk of MAYBE
deprecating it.

ChrisA

[toc] | [prev] | [next] | [standalone]


#108537 — Re: % formatting vs .format() (was: What's wrong with this concatenation statement?)

FromTim Chase <python.list@tim.thechases.com>
Date2016-05-11 18:31 -0500
SubjectRe: % formatting vs .format() (was: What's wrong with this concatenation statement?)
Message-ID<mailman.601.1463009508.32212.python-list@python.org>
In reply to#108531
On 2016-05-11 12:39, Ned Batchelder wrote:
> The docs have discussed it in a few different ways over the years.
> 
> Python 3.0 and 3.1 said:
> 
> 3.2 said:
> 
> 3.3 and up say:

I've picked up on the "% formatting not going away, .format() more
flexible" vibe but had missed the evolution in the docs to clarify
the intent. Thanks for the succinct summary of how that's changed.

-tkc


[toc] | [prev] | [next] | [standalone]


#108507 — Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

Fromsohcahtoa82@gmail.com
Date2016-05-10 17:38 -0700
SubjectRe: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)
Message-ID<208df469-b1e2-4183-a117-fa700d680235@googlegroups.com>
In reply to#108400
On Sunday, May 8, 2016 at 5:44:25 PM UTC-7, Thomas 'PointedEars' Lahn wrote:
> Also, it would be a good idea if you posted under your real name.  Internet 
> is the thing with cables; Usenet is the thing with people.  I for one tend 
> to avoid communicating with few-letter entities; exceptions to that would 
> probably include only E.T., M.J., ALF, and K.I.T.T.
> 
> -- 
> PointedEars
> 
> Twitter: @PointedEars2
> Please do not cc me. / Bitte keine Kopien per E-Mail.

I don't blame people for not wanting to use their real name on the Internet, especially if you're a woman.  There are a lot of crazy people out there that will find out where you live and send death threats just because you disagree with them or you happen to be a woman that enjoys video games or exists in the tech world.

[toc] | [prev] | [next] | [standalone]


#108530 — Re: String concatenation

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-05-11 21:14 +0200
SubjectRe: String concatenation
Message-ID<2322246.dinlaEg1Qz@PointedEars.de>
In reply to#108507
sohcahtoa82@gmail.com wrote:

> I don't blame people for not wanting to use their real name on the
> Internet, especially if you're a woman.  There are a lot of crazy people
> out there that will find out where you live and send death threats just
> because you disagree with them or you happen to be a woman that enjoys
> video games or exists in the tech world.

FUD and paranoia.  And this is _not_ the Internet.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#108532 — Re: String concatenation

Fromsohcahtoa82@gmail.com
Date2016-05-11 14:30 -0700
SubjectRe: String concatenation
Message-ID<2bb362b3-0763-422b-ac05-32b9f3a09b09@googlegroups.com>
In reply to#108530
On Wednesday, May 11, 2016 at 12:14:43 PM UTC-7, Thomas 'PointedEars' Lahn wrote:
> sohcahtoa82@gmail.com wrote:
> 
> > I don't blame people for not wanting to use their real name on the
> > Internet, especially if you're a woman.  There are a lot of crazy people
> > out there that will find out where you live and send death threats just
> > because you disagree with them or you happen to be a woman that enjoys
> > video games or exists in the tech world.
> 
> FUD and paranoia.  And this is _not_ the Internet.
> 
> -- 
> PointedEars
> 
> Twitter: @PointedEars2
> Please do not cc me. / Bitte keine Kopien per E-Mail.

You call it FUD and paranoia, I call it reality.  Are you familiar with the term "doxxing"?  Are you familiar with the shenanigans of GamerGate and Anonymous/4chan?  Or even some people on reddit.  It doesn't just happen to celebrities, either.  Is it likely to happen to me?  No, not really, but that doesn't mean I shouldn't be concerned at the possibility.

And how is this mailing list NOT part of the Internet?

[toc] | [prev] | [next] | [standalone]


#108533 — Re: String concatenation

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-05-11 14:50 -0700
SubjectRe: String concatenation
Message-ID<1bb847c1-7ac2-4c5e-a1ed-11ded09367dd@googlegroups.com>
In reply to#108532
On Wednesday, May 11, 2016 at 5:30:48 PM UTC-4, sohca...@gmail.com wrote:
> On Wednesday, May 11, 2016 at 12:14:43 PM UTC-7, Thomas 'PointedEars' Lahn wrote:
> > sohcahtoa82@gmail.com wrote:
> > 
> > > I don't blame people for not wanting to use their real name on the
> > > Internet, especially if you're a woman.  There are a lot of crazy people
> > > out there that will find out where you live and send death threats just
> > > because you disagree with them or you happen to be a woman that enjoys
> > > video games or exists in the tech world.
> > 
> > FUD and paranoia.  And this is _not_ the Internet.
> > 
> > -- 
> > PointedEars
> > 
> > Twitter: @PointedEars2
> > Please do not cc me. / Bitte keine Kopien per E-Mail.
> 
> You call it FUD and paranoia, I call it reality.  Are you familiar with the term "doxxing"?  Are you familiar with the shenanigans of GamerGate and Anonymous/4chan?  Or even some people on reddit.  It doesn't just happen to celebrities, either.  Is it likely to happen to me?  No, not really, but that doesn't mean I shouldn't be concerned at the possibility.
> 
> And how is this mailing list NOT part of the Internet?

It's really not worth debating this point.  Thomas has a fixation on people
needing to supply their real names, but is the only one who feels this way.

--NMB.

[toc] | [prev] | [next] | [standalone]


#108535 — Re: String concatenation

FromDFS <nospam@dfs.com>
Date2016-05-11 18:25 -0400
SubjectRe: String concatenation
Message-ID<nh0b9g$1mr$1@dont-email.me>
In reply to#108532
On 5/11/2016 5:30 PM, sohcahtoa82@gmail.com wrote:
> On Wednesday, May 11, 2016 at 12:14:43 PM UTC-7, Thomas 'PointedEars' Lahn wrote:
>> sohcahtoa82@gmail.com wrote:
>>
>>> I don't blame people for not wanting to use their real name on the
>>> Internet, especially if you're a woman.  There are a lot of crazy people
>>> out there that will find out where you live and send death threats just
>>> because you disagree with them or you happen to be a woman that enjoys
>>> video games or exists in the tech world.
>>
>> FUD and paranoia.  And this is _not_ the Internet.
>>
>> --
>> PointedEars
>>
>> Twitter: @PointedEars2
>> Please do not cc me. / Bitte keine Kopien per E-Mail.
>
> You call it FUD and paranoia, I call it reality.  Are you familiar with the term "doxxing"?  Are you familiar with the shenanigans of GamerGate and Anonymous/4chan?  Or even some people on reddit.  It doesn't just happen to celebrities, either.  Is it likely to happen to me?  No, not really, but that doesn't mean I shouldn't be concerned at the possibility.
>
> And how is this mailing list NOT part of the Internet?




I watched an episode of "The Internet Ruined My Life" on Syfy.

In it, an Asian girl replied #CancelColbert on twitter after the Colbert 
show made some remarks she considered racist.  Part of the eventual 
fallout was a pathetic creep watching through her window and threatening 
to kill her.

http://www.syfy.com/theinternetruinedmylife/episodes/season/1/episode/1/cancelcolbert


Unbelievable.

[toc] | [prev] | [next] | [standalone]


#108418 — Re: What's wrong with this concatenation statement?

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2016-05-09 17:53 +1000
SubjectRe: What's wrong with this concatenation statement?
Message-ID<5730420b$0$1509$c3e8da3$5496439d@news.astraweb.com>
In reply to#108397
On Monday 09 May 2016 09:10, DFS wrote:

> sSQL =  "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"

Pointlessly provocative subject line edited.

Since all three lines are constants know by the programmer at the time the 
source code is written, it should be written as:


sSQL = """line 1
line 2
line 3"""

Or if you prefer:

sSQL = "line 1\nline 2\nline 3"


Or even:

sSQL = ("line 1\n"
        "line 2\n"
        "line 3")

taking advantage of Python's compile-time implicit concatenation of string 
constants.



-- 
Steve

[toc] | [prev] | [next] | [standalone]


#108472

FromDFS <nospam@dfs.com>
Date2016-05-10 12:16 -0400
Message-ID<ngt1aa$j34$1@dont-email.me>
In reply to#108418
On 5/9/2016 3:53 AM, Steven D'Aprano wrote:
> On Monday 09 May 2016 09:10, DFS wrote:
>
>> sSQL =  "line 1\n"
>> sSQL += "line 2\n"
>> sSQL += "line 3"
>
> Pointlessly provocative subject line edited.


huh?  You called yourself a "master crafts/wo/man".

----------------------------------------------------------------------
DFS: "python is awesome, but too many options for doing the same thing 
also makes it difficult.  For me, anyway."

DuhPricko: "That's the difference between a master and an apprentice. 
The apprentice likes to follow fixed steps the same way each time. The 
master craftsman knows her tools backwards, and can choose the right 
tool for the job, and when the choice of tool really doesn't matter and 
you can use whatever happens to be the closest to hand."
----------------------------------------------------------------------



> Since all three lines are constants know by the programmer at the time the
> source code is written, it should be written as:
>
>
> sSQL = """line 1
> line 2
> line 3"""
>
> Or if you prefer:
>
> sSQL = "line 1\nline 2\nline 3"
>
>
> Or even:
>
> sSQL = ("line 1\n"
>         "line 2\n"
>         "line 3")
>
> taking advantage of Python's compile-time implicit concatenation of string
> constants.

or

sSQL = "line 1\n" \
          "line 2\n" \
          "line 3"



But no, "master", your answers are incorrect.  What's wrong with that 
concat statement is that += concatenation is frowned upon by python's 
creator, and is not recommended (in PEP8):

<quote>
Code should be written in a way that does not disadvantage other 
implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and 
such).

For example, do not rely on CPython's efficient implementation of 
in-place string concatenation for statements in the form a += b or a = a 
+ b . This optimization is fragile even in CPython (it only works for 
some types) and isn't present at all in implementations that don't use 
refcounting. In performance sensitive parts of the library, the 
''.join() form should be used instead. This will ensure that 
concatenation occurs in linear time across various implementations.
</quote>

https://www.python.org/dev/peps/pep-0008/#programming-recommendations



'master craftswoman' my ass...

[toc] | [prev] | [next] | [standalone]


#108473

FromRustom Mody <rustompmody@gmail.com>
Date2016-05-10 09:41 -0700
Message-ID<87f10da7-11a9-49fa-8466-6a7a97651130@googlegroups.com>
In reply to#108472
On Tuesday, May 10, 2016 at 9:46:45 PM UTC+5:30, DFS wrote:
> On 5/9/2016 3:53 AM, Steven D'Aprano wrote:
> > On Monday 09 May 2016 09:10, DFS wrote:
> >
> >> sSQL =  "line 1\n"
> >> sSQL += "line 2\n"
> >> sSQL += "line 3"
> >
> > Pointlessly provocative subject line edited.
> 
> 
> huh?  You called yourself a "master crafts/wo/man".
> 
> 
> DuhPricko:
> 
> 
> But no, "master", your answers are incorrect.  What's wrong with that 

> 'master craftswoman' my ass...

You do a good job

This your teacher?

https://www.youtube.com/watch?v=FMEe7JqBgvg

[toc] | [prev] | [next] | [standalone]


#108474

FromStephen Hansen <me+python@ixokai.io>
Date2016-05-10 09:42 -0700
Message-ID<mailman.566.1462898581.32212.python-list@python.org>
In reply to#108472
On Tue, May 10, 2016, at 09:16 AM, DFS wrote: 
> But no, "master", your answers are incorrect.  What's wrong with that 
> concat statement is that += concatenation is frowned upon by python's 
> creator, and is not recommended (in PEP8):
> 
> <quote>
> Code should be written in a way that does not disadvantage other 
> implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and 
> such).
> 
> For example, do not rely on CPython's efficient implementation of 
> in-place string concatenation for statements in the form a += b or a = a 
> + b . This optimization is fragile even in CPython (it only works for 
> some types) and isn't present at all in implementations that don't use 
> refcounting. In performance sensitive parts of the library, the 
> ''.join() form should be used instead. This will ensure that 
> concatenation occurs in linear time across various implementations.
> </quote>

You once again misread PEP8. 

Not one of Steven's answers used string concatenation, except for the
implicit literal concatenation, which all other implementations support.

Note:

> sSQL = """line 1
> line 2
> line 3"""

No concatenation. One string literal. Works in all implementations.

> sSQL = "line 1\nline 2\nline 3"

No concatenation. One string literal. Works in all implementations.

>
> sSQL = ("line 1\n"
>         "line 2\n"
>         "line 3")

Concatenation occurs at compile time, implicitly. Works in all
implementations.

The PEP says when building a string dynamically (that is, adding
together two strings that exist and are separate), use "".join() in
performance sensitive places. It says don't combine two strings with the
addition operator -- because while that's sometimes efficient in
CPython, the language doesn't guarantee it.

You'll notice that the one time Steven combined two strings, it was
implicitly at compile time.

In every Python implementation, it is guaranteed that:

>>> a = "a" "a"
>>> b = "aa"

Are the same. Two+ string literals are implicitly combined into one at
compile time.

> 'master craftswoman' my ass...

Yes, you're being that. Please stop.

-- 
Stephen Hansen
  m e @ i x o k a i . i o

[toc] | [prev] | [next] | [standalone]


#108494

FromDFS <nospam@dfs.com>
Date2016-05-10 18:37 -0400
Message-ID<ngtnkq$cni$2@dont-email.me>
In reply to#108474
On 5/10/2016 12:42 PM, Stephen Hansen wrote:
> On Tue, May 10, 2016, at 09:16 AM, DFS wrote:
>> But no, "master", your answers are incorrect.  What's wrong with that
>> concat statement is that += concatenation is frowned upon by python's
>> creator, and is not recommended (in PEP8):
>>
>> <quote>
>> Code should be written in a way that does not disadvantage other
>> implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and
>> such).
>>
>> For example, do not rely on CPython's efficient implementation of
>> in-place string concatenation for statements in the form a += b or a = a
>> + b . This optimization is fragile even in CPython (it only works for
>> some types) and isn't present at all in implementations that don't use
>> refcounting. In performance sensitive parts of the library, the
>> ''.join() form should be used instead. This will ensure that
>> concatenation occurs in linear time across various implementations.
>> </quote>
>
> You once again misread PEP8.


I never misread PEP8 a first time (you're referring to the multiple 
statement thing, which you were wrong about):

 From the same document:

"While sometimes it's okay to put an if/for/while with a small body on 
the same line..."

https://www.python.org/dev/peps/pep-0008/#other-recommendations

(that's twice he approves of multiple-statement lines)



And I didn't misread it here.



> Not one of Steven's answers used string concatenation,except for the
> implicit literal concatenation, which all other implementations support.
>
> Note:
>
>> sSQL = """line 1
>> line 2
>> line 3"""
>
> No concatenation. One string literal. Works in all implementations.
>
>> sSQL = "line 1\nline 2\nline 3"
>
> No concatenation. One string literal. Works in all implementations.
>
>>
>> sSQL = ("line 1\n"
>>         "line 2\n"
>>         "line 3")
>
> Concatenation occurs at compile time, implicitly. Works in all
> implementations.
>
> The PEP says when building a string dynamically (that is, adding
> together two strings that exist and are separate), use "".join() in
> performance sensitive places. It says don't combine two strings with the
> addition operator -- because while that's sometimes efficient in
> CPython, the language doesn't guarantee it.


Which is too bad, since I've used it a few times and thought it was 
nice.  It also worked for:

headerList = ["From"]
headerList += ["Date"]
headerList += ["Message-ID"]



> You'll notice that the one time Steven combined two strings, it was
> implicitly at compile time.
>
> In every Python implementation, it is guaranteed that:
>
>>>> a = "a" "a"
>>>> b = "aa"
>
> Are the same. Two+ string literals are implicitly combined into one at
> compile time.
>
>> 'master craftswoman' my ass...
>
> Yes, you're being that. Please stop.


When DuhPricko stops being so smug and condescending I will.

[toc] | [prev] | [next] | [standalone]


#108475

FromSteven D'Aprano <steve@pearwood.info>
Date2016-05-11 02:44 +1000
Message-ID<57320fd5$0$1610$c3e8da3$5496439d@news.astraweb.com>
In reply to#108472
On Wed, 11 May 2016 02:16 am, DFS wrote:

> huh?  You called yourself a "master crafts/wo/man".
[...]
> DuhPricko


*plonk*


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#108481

FromIan Kelly <ian.g.kelly@gmail.com>
Date2016-05-10 12:15 -0600
Message-ID<mailman.571.1462904167.32212.python-list@python.org>
In reply to#108472
On Tue, May 10, 2016 at 10:16 AM, DFS <nospam@dfs.com> wrote:
> On 5/9/2016 3:53 AM, Steven D'Aprano wrote:
>>
>> On Monday 09 May 2016 09:10, DFS wrote:
>>
>>> sSQL =  "line 1\n"
>>> sSQL += "line 2\n"
>>> sSQL += "line 3"
>>
>>
>> Pointlessly provocative subject line edited.
>
>
>
> huh?  You called yourself a "master crafts/wo/man".

Stop trolling.

> ----------------------------------------------------------------------
> DFS: "python is awesome, but too many options for doing the same thing also
> makes it difficult.  For me, anyway."
>
> DuhPricko: "That's the difference between a master and an apprentice. The
> apprentice likes to follow fixed steps the same way each time. The master
> craftsman knows her tools backwards, and can choose the right tool for the
> job, and when the choice of tool really doesn't matter and you can use
> whatever happens to be the closest to hand."
> ----------------------------------------------------------------------

So what, you're upset by the implication that you haven't already
mastered Python when you apparently just started a couple months ago?
Temper your expectations.

> 'master craftswoman' my ass...

Take your gender insults somewhere else. They're not welcome here.

[toc] | [prev] | [next] | [standalone]


#108490

FromDFS <nospam@dfs.com>
Date2016-05-10 17:21 -0400
Message-ID<ngtj5u$pqh$1@dont-email.me>
In reply to#108481
On 5/10/2016 2:15 PM, Ian Kelly wrote:
> On Tue, May 10, 2016 at 10:16 AM, DFS <nospam@dfs.com> wrote:
>> On 5/9/2016 3:53 AM, Steven D'Aprano wrote:
>>>
>>> On Monday 09 May 2016 09:10, DFS wrote:
>>>
>>>> sSQL =  "line 1\n"
>>>> sSQL += "line 2\n"
>>>> sSQL += "line 3"
>>>
>>>
>>> Pointlessly provocative subject line edited.
>>
>>
>>
>> huh?  You called yourself a "master crafts/wo/man".
>
> Stop trolling.


Challenging someone's boastful claim isn't trolling.



>> ----------------------------------------------------------------------
>> DFS: "python is awesome, but too many options for doing the same thing also
>> makes it difficult.  For me, anyway."
>>
>> DuhPricko: "That's the difference between a master and an apprentice. The
>> apprentice likes to follow fixed steps the same way each time. The master
>> craftsman knows her tools backwards, and can choose the right tool for the
>> job, and when the choice of tool really doesn't matter and you can use
>> whatever happens to be the closest to hand."
>> ----------------------------------------------------------------------
>
> So what, you're upset by the implication that you haven't already
> mastered Python when you apparently just started a couple months ago?
> Temper your expectations.


Of course that wasn't my expectation.  That would be crazy...

My expectation was to not be met by smug, sanctimonious and 
condescending replies from the likes of DuhPricko.



>> 'master craftswoman' my ass...
>
> Take your gender insults somewhere else. They're not welcome here.

Take your net-nannying somewhere else.  It's not welcome /anywhere/.

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web