Python, are you ill?
Nicolas Dandrimont
nicolas.dandrimont at gmail.com
Sat May 10 17:13:10 EDT 2008
* wxPythoner at gmail.com <wxPythoner at gmail.com> [2008-05-10 13:59:37 -0700]:
> If you are in the interactive prompt of the Python interpreter and you
> do this
>
> print """Testing\""" or print '''Testing\'''
>
> you get three dots [...] as if Python expects a code block. If you
> press Enter, you get three dots again, and again, and again... You
> can't get out of the code block with pressing the Enter key;
That is because Python expects you to end the triple-quoted string with
three unescaped quotes.
> you have to press Ctrl+Z (if you're in Linux) in order to get out of that code
> block, which then throws you back to the Linux command line, but
> before that it prints this line
>
> [1]+ Stopped python
>
That ^Z just suspends your Python interpreter. It has become a job you can
now bring to foreground again with "fg". (but it's a feature of your
shell, not of Python)
>
> If you do
>
> print "Testing\" or print 'Testing\'
>
> you get an error, but not of you use the triple quotes. Is that a bug
> in the interpreter perhaps?
The fact is, that triple-quoted strings can span on multiple lines, and
that single-quoted strings cannot (without the line ending with a "\").
So no, it's not a bug in the interpreter.
Regards,
--
Nicolas Dandrimont
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20080510/884a3c25/attachment-0001.sig>
More information about the Python-list
mailing list