Vedr: What does """ means in python?
Gisle Vanem
gvanem at yahoo.no
Sun Feb 9 00:49:31 EST 2014
Gisle V.
"Computers are useless. They can only give answers" --Pablo Picasso
Chris Angelico <rosuav at gmail.com> wrote:
> For SQL? Ignore the extra spaces, it's a free-form language. The only
> reason to consider dedent() would be if you're worried about how your
> log files will look. The actual execution of SQL won't be bothered by
> newlines and spaces/tabs.
Regrading handy uses of ''', you learned me one trick when using Python
code in a Windows .bat file:
rem = '''
@echo off
echo This is
batch
\python32\python %0
echo All done
exit /b
rem '''
import
sys
print("This is Python")
for i,p in
enumerate(sys.path):
print('sys.path[%2d]: %s' % (i, p))
print("Python
done")
You'll have a variable in Python called 'rem' which contains all
your
batch code :) It exploits the fact that 'rem' makes a
one-line
comment, but the triple quotes go across multiple lines.
More information about the Python-list
mailing list