Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108397 > unrolled thread
| Started by | DFS <nospam@dfs.com> |
|---|---|
| First post | 2016-05-08 19:10 -0400 |
| Last post | 2016-05-12 18:40 +1000 |
| Articles | 20 on this page of 59 — 22 participants |
Back to article view | Back to comp.lang.python
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 1 of 3 [1] 2 3 Next page →
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-05-08 19:10 -0400 |
| Subject | Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? |
| Message-ID | <ngogql$bgm$1@dont-email.me> |
sSQL = "line 1\n" sSQL += "line 2\n" sSQL += "line 3"
[toc] | [next] | [standalone]
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2016-05-08 18:37 -0500 |
| Message-ID | <mailman.536.1462752047.32212.python-list@python.org> |
| In reply to | #108397 |
While I'm not Steven...
On 2016-05-08 19:10, DFS wrote:
> sSQL = "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"
If you're only doing it once, it's adequate.
If you're doing it within a loop
for thing in some_iter():
s = "line1\n"
s += "line2\n"
s += "line3"
use(s, thing)
it's suboptimal. Solutions include hoisting it out of the loop:
s = "line1\n"
s += "line2\n"
s += "line3"
for thing in some_iter():
use(s, thing)
and just specifying it with a multi-line string (still better off
hoisted out of the loop):
s = """line1
line2
line3"""
for thing in some_iter():
use(s, thing)
If you're accruing in a loop
s = ""
for thing in some_iter():
s += mung(thing)
then that's a bad code-smell (you get quadratic behavior as the
strings are constantly resized), usually better replaced with
s = "".join(mung(thing) for thing in some_iter())
or build them up as a list, then join the results:
lst = []
for thing in some_iter():
if should_use(thing):
lst.append(thing)
s = "\n".join(lst)
-tkc
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2016-05-08 20:02 -0400 |
| Message-ID | <mailman.537.1462752147.32212.python-list@python.org> |
| In reply to | #108397 |
On Sun, May 8, 2016 at 7:10 PM, DFS <nospam@dfs.com> wrote: > sSQL = "line 1\n" > sSQL += "line 2\n" > sSQL += "line 3" > -- > https://mail.python.org/mailman/listinfo/python-list What is your point DFS? You found pylint, and you don't like what it tells you. Its a tool, and it can tell you some things. Your code seems to be a mix of tabs and spaces, and you don't like standard python practices. That's fine, coding is (at least alone) an individual pursuit. You can code anyway you like. But, learning from the work of others, can be awfully useful. Most people I know use spaces, they set their text editor up to make tabs turn into 4 spaces. Problem solved. As far as wanting to put several statements on a line, you can do that if you like, but others have concluded that the code is easier to read if you don't. If that isn't your view, do what you like. It depends upon what problems you want to fight. If you adhere to standards, your code is more easily reviewed and easier to get help from others, if that is what you ask. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-05-09 02:44 +0200 |
| Subject | String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) |
| Message-ID | <3414323.Mt0gs2Yp5W@PointedEars.de> |
| In reply to | #108397 |
DFS wrote:
> sSQL = "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"
What is wrong with it in Python is that it is unnecessarily inefficient.
Python has implicit string concatenation if all operands are string
literals:
#-----------------------------------------------------------------------
sSQL = ("line 1\n"
"line 2\n"
"line 3")
#-----------------------------------------------------------------------
Alternatively, you can join a list of strings:
#-----------------------------------------------------------------------
sSQL = "\n".join([
"line 1",
"line 2",
"line 3",
])
#-----------------------------------------------------------------------
Python also has a way that avoids using several string literals:
#-----------------------------------------------------------------------
sSQL = """line 1
line 2
line 3"""
#-----------------------------------------------------------------------
or (to have the text aligned)
#-----------------------------------------------------------------------
sSQL = """\
line 1
line 2
line 3"""
#-----------------------------------------------------------------------
With the “%” string operator (deprecated), str.format(), and str.Template,
you can use other values in string values even without concatenation.
Next time, RTFM first:
<https://docs.python.org/3.5/tutorial/introduction.html#strings> p.
Finally, with SQL you should prefer Prepared Statements and Stored
Procedures, not bare strings, to avoid SQL injection:
<https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet>
And if you want to communicate only with a specific person, I strongly
suggest you send *them* an *e-mail* instead of to the newsgroup/mailing
list.
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.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-05-09 12:16 +1000 |
| Subject | Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) |
| Message-ID | <mailman.538.1462760201.32212.python-list@python.org> |
| In reply to | #108400 |
On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: > With the “%” string operator (deprecated), str.format(), and str.Template, > you can use other values in string values even without concatenation. Not deprecated. Don't spread FUD. > Finally, with SQL you should prefer Prepared Statements and Stored > Procedures, not bare strings, to avoid SQL injection: > > <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet> He is safe. He's using parameterized queries. > 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. I'm not using Usenet, Mr PointedEars. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-05-09 23:21 +0200 |
| Subject | Re: String concatenation |
| Message-ID | <2279805.ZaV9TF1YuJ@PointedEars.de> |
| In reply to | #108403 |
Chris Angelico wrote: > On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn > <PointedEars@web.de> wrote: >> With the “%” string operator (deprecated), str.format(), and >> str.Template, you can use other values in string values even without >> concatenation. > > Not deprecated. Don't spread FUD. If only you cared to read what I referred to: ,-<https://docs.python.org/3/library/stdtypes.html#old-string-formatting> | | 4.7.2. 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. Note the key words: “old”, “quirks”, “errors”. >> Finally, with SQL you should prefer Prepared Statements and Stored >> Procedures, not bare strings, to avoid SQL injection: >> >> <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet> > > He is safe. He's using parameterized queries. How do you know? >> 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. > > I'm not using Usenet, Mr PointedEars. I don’t care. This basic courtesy extended to strangers whose help you seek originates in real life, not Usenet. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2016-05-10 12:32 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <57314838$0$1586$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #108439 |
On Tue, 10 May 2016 07:21 am, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn >> <PointedEars@web.de> wrote: >>> With the “%” string operator (deprecated), str.format(), and >>> str.Template, you can use other values in string values even without >>> concatenation. >> >> Not deprecated. Don't spread FUD. > > If only you cared to read what I referred to: > > ,-<https://docs.python.org/3/library/stdtypes.html#old-string-formatting> That is excellent advice Thomas! If only you had followed it yourself, instead of blindly and mechanically copying and pasting. If you had bothered to actually read it, you would have seen that *nowhere* does it say that the % string operator is deprecated. Deprecation has a specific meaning involving a formal process of removing a feature from the language. It doesn't merely mean "this old feature has quirks and we think you should use this new feature instead". Some of the core developers like `format` better and think that people should use it in preference to the % string operator. That much is true. But that is far from being deprecated. > Note the key words: “old”, “quirks”, “errors”. Irrelevant to the question of deprecation. Floats are old (they go back to the first release of Python), they have many quirks (x + y - x is not necessarily equal to y), and people make many errors with floats. Does this mean they are deprecated? Of course not. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-05-10 12:42 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <mailman.555.1462848158.32212.python-list@python.org> |
| In reply to | #108445 |
On Tue, May 10, 2016 at 12:32 PM, Steven D'Aprano <steve@pearwood.info> wrote: > Floats are old (they go back to the first release of Python), they have many > quirks (x + y - x is not necessarily equal to y), and people make many > errors with floats. Does this mean they are deprecated? Of course not. Careful there Steven - now that cdecimal is in core, people might start saying that. Particularly if (as is periodically requested, and which I think would be a good idea) Decimal literals become a thing. And the removal of core types HAS happened. Correct me if I'm wrong, but didn't the first release of Python have only the short integer type, and then a completely new 'long' type was added? Automatic promotion blurred the distinction, and then Python 3.0 removed the 'int' type and renamed 'long'. So it's theoretically possible for Decimal to replace float... ... except that that would actually be a bad idea, which a lot of people don't realize. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2016-05-12 17:43 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <5734340d$0$2804$c3e8da3$76491128@news.astraweb.com> |
| In reply to | #108446 |
On Tuesday 10 May 2016 12:42, Chris Angelico wrote: > On Tue, May 10, 2016 at 12:32 PM, Steven D'Aprano <steve@pearwood.info> > wrote: >> Floats are old (they go back to the first release of Python), they have >> many quirks (x + y - x is not necessarily equal to y), and people make >> many errors with floats. Does this mean they are deprecated? Of course >> not. > > Careful there Steven - now that cdecimal is in core, people might > start saying that. They *might*, but they haven't *yet*. And people can say all sorts of things, doesn't make them true. > Particularly if (as is periodically requested, and > which I think would be a good idea) Decimal literals become a thing. > And the removal of core types HAS happened. Correct me if I'm wrong, > but didn't the first release of Python have only the short integer > type, and then a completely new 'long' type was added? The oldest Python I have installed is 0.9.1, which not only lacks the L suffix, but it also lacks ** for exponentiation. There's also no "long" type: >>> n = 2 >>> for i in range(100): ... n = n * 2 ... Unhandled exception: run-time error: integer overflow Stack backtrace (innermost last): File "<stdin>", line 2 > Automatic > promotion blurred the distinction, and then Python 3.0 removed the > 'int' type and renamed 'long'. So it's theoretically possible for > Decimal to replace float... > > ... except that that would actually be a bad idea, which a lot of > people don't realize. Indeed. Decimal might not be old, but it does have quirks and it can certainly lead to errors (both misuse and rounding errors, among others). It is subject to the same sorts of floating point issues as binary floats. -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2016-05-09 20:45 -0700 |
| Subject | Re: String concatenation |
| Message-ID | <a52b14bd-6dc9-4d93-8d32-0abebdb8ec1a@googlegroups.com> |
| In reply to | #108439 |
On Tuesday, May 10, 2016 at 2:52:13 AM UTC+5:30, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > > > On Mon, May 9, 2016 at 10:44 AM, 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. > > > > I'm not using Usenet, Mr PointedEars. > > I don't care. This basic courtesy extended to strangers whose help you seek > originates in real life, not Usenet. And it is objectionable to discriminate on people's names; the same way it is objectionable to discriminate on people's skin-color, religion, country, sex etc See: http://www.alphr.com/computing/1000378/facebook-rejects-native-american-names-as-fake-again
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2016-05-10 16:46 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <573183b1$0$2741$c3e8da3$76491128@news.astraweb.com> |
| In reply to | #108447 |
On Tuesday 10 May 2016 13:45, Rustom Mody wrote:
> See:
> http://www.alphr.com/computing/1000378/facebook-rejects-native-american-
names-as-fake-again
Somebody should set up a kick-starter to pay someone to change their legal
name to "Facebook-Are-Arseholes", then open a Facebook account with it. I'd
contribute a couple of bucks.
("That's MISTER Facebook-Are-Arseholes to you!")
Unfortunately, Australia's naming laws almost certainly wouldn't allow such
a name. But I think the US would.
--
Steve
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2016-05-10 00:13 -0700 |
| Subject | Re: String concatenation |
| Message-ID | <87twi675cg.fsf@jester.gateway.pace.com> |
| In reply to | #108452 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: > Australia's naming laws almost certainly wouldn't allow such a name. https://en.wikipedia.org/wiki/Facebook_real-name_policy_controversy#Vietnamese
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2016-05-10 17:54 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <573193a0$0$11094$c3e8da3@news.astraweb.com> |
| In reply to | #108454 |
On Tuesday 10 May 2016 17:13, Paul Rubin wrote: > Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: >> Australia's naming laws almost certainly wouldn't allow such a name. > > https://en.wikipedia.org/wiki/Facebook_real- name_policy_controversy#Vietnamese "Phuc Dat Bich" was a hoax, but it probably would be allowed in Australia. I'm surprised that Spanish names are not affected. Consider a woman who goes by the personal name of Maria Teresa, whose father's first surname was García and mother's first surname was Ramírez. Her name would therefore be Maria Teresa García Ramírez. If she marries Elí Arroyo López, then she might change her name to Maria Teresa García Ramírez de Arroyo. With six words, that would fall foul of Facebook's foul naming policy. http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ -- Steve
[toc] | [prev] | [next] | [standalone]
| From | David Palao <dpalao.python@gmail.com> |
|---|---|
| Date | 2016-05-10 10:15 +0200 |
| Subject | Re: String concatenation |
| Message-ID | <mailman.557.1462868155.32212.python-list@python.org> |
| In reply to | #108455 |
2016-05-10 9:54 GMT+02:00 Steven D'Aprano <steve+comp.lang.python@pearwood.info>: > On Tuesday 10 May 2016 17:13, Paul Rubin wrote: > >> Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: >>> Australia's naming laws almost certainly wouldn't allow such a name. >> >> https://en.wikipedia.org/wiki/Facebook_real- > name_policy_controversy#Vietnamese > > "Phuc Dat Bich" was a hoax, but it probably would be allowed in Australia. > > I'm surprised that Spanish names are not affected. Consider a woman who goes by > the personal name of Maria Teresa, whose father's first surname was García and > mother's first surname was Ramírez. Her name would therefore be Maria Teresa > García Ramírez. If she marries Elí Arroyo López, then she might change her name > to Maria Teresa García Ramírez de Arroyo. With six words, that would fall foul > of Facebook's foul naming policy. > > > http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ > > > -- > Steve > > -- > https://mail.python.org/mailman/listinfo/python-list In Spain "de Arroyo" officially does not become part of the name. The same applies to other countries as well. Not 100% sure that it is true in every Spanish speaking country though. Best
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2016-05-12 17:27 +1000 |
| Subject | Re: String concatenation |
| Message-ID | <57343078$0$1509$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #108456 |
On Tuesday 10 May 2016 18:15, David Palao wrote: > 2016-05-10 9:54 GMT+02:00 Steven D'Aprano > <steve+comp.lang.python@pearwood.info>: >> I'm surprised that Spanish names are not affected. Consider a woman who goes >> by the personal name of Maria Teresa, whose father's first surname was >> García and mother's first surname was Ramírez. Her name would therefore be >> Maria Teresa García Ramírez. If she marries Elí Arroyo López, then she might >> change her name to Maria Teresa García Ramírez de Arroyo. With six words, >> that would fall foul of Facebook's foul naming policy. > In Spain "de Arroyo" officially does not become part of the name. The > same applies to other countries as well. Not 100% sure that it is true > in every Spanish speaking country though. Thanks for the clarification David. Nevertheless, whether it is part of her *legal* name or not, some Spanish women prefer to use her husband's name as part of her preferred real name, that is, the name she answers to and the name she prefers to sign on correspondence. Maybe it's a generation thing? Perhaps in Spain the women using Facebook and the women taking their husband's name don't intersect? -- Steve
[toc] | [prev] | [next] | [standalone]
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| Date | 2016-05-09 09:01 +0530 |
| Subject | Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) |
| Message-ID | <mailman.540.1462764685.32212.python-list@python.org> |
| In reply to | #108400 |
f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubffffbv GB hbu hbu fjbjfbbbufhbvh VB have fbbbbqbgvfb NB bb GB GB GB GB bbu GB vu GB vu GB GB b GB fbufjnb BH GB GB bvvfbubffffbjubuv GB b fbufbbby GB bfffffff GB f GB bbbu GB GB ffinj GB vh vh fjb GB fj GB h h GB gjfthey're the b GB gjf GBG GBG q GB fbb b bh VB ffbff GBG fbfvrgv On May 9, 2016 7:49 AM, "Chris Angelico" <rosuav@gmail.com> wrote: On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote: > With the “%” string operator (deprecated), str.format(), and str.Template, > you can use other values in string values even without concatenation. Not deprecated. Don't spread FUD. > Finally, with SQL you should prefer Prepared Statements and Stored > Procedures, not bare strings, to avoid SQL injection: > > <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet> He is safe. He's using parameterized queries. > 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. I'm not using Usenet, Mr PointedEars. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [next] | [standalone]
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| Date | 2016-05-09 09:13 +0530 |
| Subject | Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) |
| Message-ID | <mailman.541.1462765416.32212.python-list@python.org> |
| In reply to | #108400 |
I'm so sorry, forgot to lock my phone. On May 9, 2016 9:01 AM, "srinivas devaki" <mr.eightnoteight@gmail.com> wrote: > f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubffffbv GB hbu hbu > fjbjfbbbufhbvh VB have fbbbbqbgvfb NB bb GB GB GB GB bbu GB vu GB vu GB GB > b GB fbufjnb BH GB GB bvvfbubffffbjubuv GB b fbufbbby GB bfffffff GB f GB > bbbu GB GB ffinj GB vh vh fjb GB fj GB h h GB gjfthey're the b GB gjf GBG > GBG q GB fbb b bh VB ffbff GBG fbfvrgv > On May 9, 2016 7:49 AM, "Chris Angelico" <rosuav@gmail.com> wrote: > > On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn > <PointedEars@web.de> wrote: > > With the “%” string operator (deprecated), str.format(), and > str.Template, > > you can use other values in string values even without concatenation. > > Not deprecated. Don't spread FUD. > > > Finally, with SQL you should prefer Prepared Statements and Stored > > Procedures, not bare strings, to avoid SQL injection: > > > > <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet> > > He is safe. He's using parameterized queries. > > > 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. > > I'm not using Usenet, Mr PointedEars. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > >
[toc] | [prev] | [next] | [standalone]
| From | Michael Selik <michael.selik@gmail.com> |
|---|---|
| Date | 2016-05-09 18:29 +0000 |
| Subject | Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?) |
| Message-ID | <mailman.548.1462818564.32212.python-list@python.org> |
| In reply to | #108400 |
You're saying that wasn't a coded message? On Sun, May 8, 2016, 10:44 PM srinivas devaki <mr.eightnoteight@gmail.com> wrote: > I'm so sorry, forgot to lock my phone. > On May 9, 2016 9:01 AM, "srinivas devaki" <mr.eightnoteight@gmail.com> > wrote: > > > f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubffffbv GB hbu hbu > > fjbjfbbbufhbvh VB have fbbbbqbgvfb NB bb GB GB GB GB bbu GB vu GB vu GB > GB > > b GB fbufjnb BH GB GB bvvfbubffffbjubuv GB b fbufbbby GB bfffffff GB f GB > > bbbu GB GB ffinj GB vh vh fjb GB fj GB h h GB gjfthey're the b GB gjf GBG > > GBG q GB fbb b bh VB ffbff GBG fbfvrgv > > On May 9, 2016 7:49 AM, "Chris Angelico" <rosuav@gmail.com> wrote: > > > > On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn > > <PointedEars@web.de> wrote: > > > With the “%” string operator (deprecated), str.format(), and > > str.Template, > > > you can use other values in string values even without concatenation. > > > > Not deprecated. Don't spread FUD. > > > > > Finally, with SQL you should prefer Prepared Statements and Stored > > > Procedures, not bare strings, to avoid SQL injection: > > > > > > <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet> > > > > He is safe. He's using parameterized queries. > > > > > 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. > > > > I'm not using Usenet, Mr PointedEars. > > > > ChrisA > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@dfs.com> |
|---|---|
| Date | 2016-05-10 19:53 -0400 |
| Message-ID | <ngts2t$ok8$2@dont-email.me> |
| In reply to | #108400 |
On 5/8/2016 8:44 PM, Thomas 'PointedEars' Lahn wrote:
> DFS wrote:
>
>> sSQL = "line 1\n"
>> sSQL += "line 2\n"
>> sSQL += "line 3"
>
> What is wrong with it in Python is that it is unnecessarily inefficient.
> Python has implicit string concatenation if all operands are string
> literals:
>
> #-----------------------------------------------------------------------
> sSQL = ("line 1\n"
> "line 2\n"
> "line 3")
> #-----------------------------------------------------------------------
>
> Alternatively, you can join a list of strings:
>
> #-----------------------------------------------------------------------
> sSQL = "\n".join([
> "line 1",
> "line 2",
> "line 3",
> ])
> #-----------------------------------------------------------------------
>
> Python also has a way that avoids using several string literals:
>
> #-----------------------------------------------------------------------
> sSQL = """line 1
> line 2
> line 3"""
> #-----------------------------------------------------------------------
>
> or (to have the text aligned)
>
> #-----------------------------------------------------------------------
> sSQL = """\
> line 1
> line 2
> line 3"""
> #-----------------------------------------------------------------------
or
sSQL = "line 1\n" \
"line 2\n" \
"line 3"
> With the “%” string operator (deprecated),
according to who?
> str.format(), and str.Template,
> you can use other values in string values even without concatenation.
> Next time, RTFM first:
Ironically, PointyHead, YOU didn't read the manual, and didn't provide
the answer I was looking for. And it's a doozy - I think you'll be
surprised.
> <https://docs.python.org/3.5/tutorial/introduction.html#strings> p.
>
> Finally, with SQL you should prefer Prepared Statements and Stored
> Procedures, not bare strings, to avoid SQL injection:
>
> <https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet>
Who says I don't?
> And if you want to communicate only with a specific person, I strongly
> suggest you send *them* an *e-mail* instead of to the newsgroup/mailing
> list.
huh? You just communicated with a specific person.
> Also, it would be a good idea if you posted under your real name.
It would be a /supremely/ bad idea for me to do that.
What would be a good idea is for you not to change the Subject line of
my threads.
> 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?
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-05-11 02:16 +0200 |
| Message-ID | <21232585.YymZx1Mvhl@PointedEars.de> |
| In reply to | #108502 |
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.
>> 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?)
.
.
.
.
.
.
.
.
.
.
.
.
.
--
PointedEars
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web