Re: Python gotcha of the day

2018-03-15 Thread Python
On Thu, Mar 15, 2018 at 10:21:24AM +0100, Thomas Jollans wrote: > On 2018-03-15 07:11, Ben Finney wrote: > > Steven D'Aprano writes: > > > >> py> """\"" [...] > Then riddle me this: > > if """\"" is equivalent to "" + "\"" + "" + "", then why isn't

Re: Python gotcha of the day

2018-03-15 Thread Ben Finney
Thomas Jollans writes: > Then riddle me this: > > if """\"" is equivalent to "" + "\"" + "" + "", then why isn't > """ \""" """ equivalent to "" + " \"" + " " + ""? Who can say? I was only asked for an explanation, not a consistent one :-) Perhaps it's a micro-optimisation,

Re: Python gotcha of the day

2018-03-15 Thread Thomas Jollans
On 2018-03-15 07:11, Ben Finney wrote: > Steven D'Aprano writes: > >> py> """\"" >> '"' > > That's an empty string delimited by ‘"’; followed by a double-quote > character, escaped, delimited by ‘"’; followed by two more empty > strings. They

Re: Python gotcha of the day

2018-03-15 Thread Ben Finney
Steven D'Aprano writes: > py> """\"" > '"' That's an empty string delimited by ‘"’; followed by a double-quote character, escaped, delimited by ‘"’; followed by two more empty strings. They concatenate to a single one-character string. Equivalent to

Re: Python gotcha of the day

2018-03-14 Thread Brian Oney via Python-list
explicit is better than implicit. That gives me an idea for a module with the following debugging command line functionality. import sass >>> "" ":p" Traceback: Are you telling me that ' ' is supposed to an operator? (Rock thrown) On March 14, 2018 10:40:38 AM GMT+01:00, Thomas Jollans

Re: Python gotcha of the day

2018-03-14 Thread Thomas Jollans
On 2018-03-14 05:08, Steven D'Aprano wrote: > Explain the difference between these two triple-quoted strings: > > Here is a triple-quoted string containing spaces and a triple-quote: > > py> """ \""" """ > ' """ ' > > > But remove the spaces, and two of the quotation marks disappear: > > py>

Re: Python gotcha of the day

2018-03-13 Thread Bill
Dan Sommers wrote: On Wed, 14 Mar 2018 04:08:30 +, Steven D'Aprano wrote: Explain the difference between these two triple-quoted strings: But remove the spaces, and two of the quotation marks disappear: py> """\"" '"' That's (a) a triple quoted string containing a single escaped

Re: Python gotcha of the day

2018-03-13 Thread Cameron Simpson
On 14Mar2018 04:08, Steven D'Aprano wrote: Explain the difference between these two triple-quoted strings: Here is a triple-quoted string containing spaces and a triple-quote: py> """ \""" """ ' """ ' But remove the spaces, and two of the quotation

Re: Python gotcha of the day

2018-03-13 Thread Dan Sommers
On Wed, 14 Mar 2018 04:08:30 +, Steven D'Aprano wrote: > Explain the difference between these two triple-quoted strings: > But remove the spaces, and two of the quotation marks disappear: > > py> """\"" > '"' That's (a) a triple quoted string containing a single escaped quote, followed

Python gotcha of the day

2018-03-13 Thread Steven D'Aprano
Explain the difference between these two triple-quoted strings: Here is a triple-quoted string containing spaces and a triple-quote: py> """ \""" """ ' """ ' But remove the spaces, and two of the quotation marks disappear: py> """\"" '"' If nobody gets the answer, I shall reveal all