Python gotcha of the day
Ben Finney
ben+python at benfinney.id.au
Thu Mar 15 14:59:49 EDT 2018
Thomas Jollans <tjol at tjol.eu> 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, to create more empty strings that can
be discarded quickly. Perhaps not.
> As I said earlier: I initially thought the way you're thinking, but got
> stuck at that question and had to back-track my reasoning :-)
I was not hindered by the burden to make my explanation work for
everything, just for the one example presented. This allowed me to
quickly get back to feeding my goldfish.
--
\ “What do religious fundamentalists and big media corporations |
`\ have in common? They believe that they own culture, they are so |
_o__) self-righteous about it …” —Nina Paley, 2011 |
Ben Finney
More information about the Python-list
mailing list