On 2012-09-19 14:18, Terry Reedy wrote:
stating correctly that it works for exec().

My mistake. I fancied you were talking shell, not python. I now see that Python 3 has exec() as a built-in.

python -c "exec('print(\"hi\")\nif 0:\n print(\"hi\")\nelif 1:\n print(\"hi2\")')"
worked right off the *.bat. Shades of sed!
Note I used a one space indentation. A tab works fine, too.

python -c "exec('print(%1)\nif 1: print(2)')"
and calling 'tem 3' prints
3
2
Thanks for the exhaustive study. :-) I'll keep it in mind. I hope I don't have to do this, though.

That said, if you have many multiline statements, putting them in a
separate file or files may be a good idea.

ASAP I'm hoping to have each bat swallowed completely by python. My current "bathon" or "pytch" file closes an old session then opens the session I select just like the bat mom used to bake.

Thank you again, Terry, and thanks to all -- even the *nix'ers. Might come in handy if I get back into that again.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to