Re: Python, are you ill?

2008-05-11 Thread castironpi
On May 11, 6:26 pm, Tim Roberts <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
> >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.
>
> ...which it does.
>
> >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; you have
> >to press Ctrl+Z (if you're in Linux) in order to get out of that code
> >block,
>
> No, you don't.  You can also enter """ or ''' to properly close the quote.
>
> >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?
>
> As a general rule, when you are just beginning to learn some product, it is
> safe to assume that anything you see as a bug in the product is almost
> certainly a flaw in your understanding of the product.
> --
> Tim Roberts, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.

I hold further, it is more profitable, unless you can change it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, are you ill?

2008-05-11 Thread Tim Roberts
[EMAIL PROTECTED] wrote:
>
>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.

...which it does.

>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; you have
>to press Ctrl+Z (if you're in Linux) in order to get out of that code
>block, 

No, you don't.  You can also enter """ or ''' to properly close the quote.

>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?

As a general rule, when you are just beginning to learn some product, it is
safe to assume that anything you see as a bug in the product is almost
certainly a flaw in your understanding of the product.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, are you ill?

2008-05-10 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote:
> You
> can't get out of the code block with pressing the Enter key; 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

You can use Ctrl+C and Python will stop what it's doing and go back to
its main prompt.
-- 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, are you ill?

2008-05-10 Thread Nicolas Dandrimont
* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [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



signature.asc
Description: Digital signature
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python, are you ill?

2008-05-10 Thread John Henderson
[EMAIL PROTECTED] wrote:

> 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; 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
> 
> 
> 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?

>>> print """testing\"""
"""
testing"""

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


Re: Python, are you ill?

2008-05-10 Thread John Machin
On May 11, 6:59 am, [EMAIL PROTECTED] wrote:
> 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; 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
>
> 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?

No. This might clue you in:

>>> print """Testing\
Testing"
>>>

Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, are you ill?

2008-05-10 Thread Ludwig
This is not a bug, this is how it should work.

A triple quoted string ends only with another triple quoted string (which
can extend over multiple lines) In your example you are escaping the first
quote character at the end of the line, thus leaving just two quotes that do
not end the string.
Another """ (triple quote) will terminate the string.

HTH


2008/5/10 <[EMAIL PROTECTED]>:

> 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; 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
>
>
> 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?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Python, are you ill?

2008-05-10 Thread wxPythoner
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; 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


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?
--
http://mail.python.org/mailman/listinfo/python-list