Since there are no single-quotes in there, one can simply
echo 'print string.join(sys.version.split(" ")[0].split(".")[0:2],".")' >> $queryfile
without any backslashes. Who said that configure scripts must look like line noise?

If you would like to refer to this comment somewhere else in this project, copy and paste the following link: