Python gotcha of the day

Ben Finney ben+python at benfinney.id.au
Thu Mar 15 02:11:43 EDT 2018


Steven D'Aprano <steve+comp.lang.python at pearwood.info> 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
 "" + "\"" + "" + ""
without the ‘+’ operations.
> If nobody gets the answer, I shall reveal all later.

My interpretation may not be how the language defines it; but it does
match the result!
-- 
 \ “I have yet to see any problem, however complicated, which, |
 `\ when you looked at it in the right way, did not become still |
_o__) more complicated.” —Paul Anderson |
Ben Finney


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /