Hi,

Karsten Hilbert:
> Writing '''' would make the first quote escape the second.
> 
Not escape, but …

> Or some such :-)
> 
To make this more explicit:

foo=''' '
echo This is Shell code
exec python $0
' '''
print("This is Python")

So to Python, you have a (multiline, hence the triple-quote) string which
contains of a space and a single quote, a linefeed, random text, and the
reverse linefeed-singlequote-space combo.

To the shell, $foo is a single space.

In fact, I would do this slightly differently:

#!/bin/sh
# -*- coding: utf-8 -*-

shell_code=''' '
echo This is Shell
exec python $0

python_code='''
## ONLY use DOUBLE quotes ‹"› after this line
print("This is Python")

# End of Python code. Do not modify this line. #'

This way, "dash -n $SCRIPT" will ignore the Python code
(since it's a string) and not report a syntax error.

-- 
-- Matthias Urlichs


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140721095510.ga15...@smurf.noris.de

Reply via email to