From 75d82a20e0933804991235e51df0fb14d65fe24f Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Thu, 13 May 2010 23:58:04 -0400 Subject: [PATCH] missing period --- porting-code-to-python-3-with-2to3.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index 1a0448d..e7b1756 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -51,7 +51,7 @@
  1. To print a blank line, call print() without any arguments. -
  2. To print a single value, call print() with one argument +
  3. To print a single value, call print() with one argument.
  4. To print two values separated by a space, call print() with two arguments.
  5. This one is a little tricky. In Python 2, if you ended a print statement with a comma, it would print the values separated by spaces, then print a trailing space, then stop without printing a carriage return. (Technically, it’s a little more complicated than that. The print statement in Python 2 used a now-deprecated attribute called softspace. Instead of printing a space, Python 2 would set sys.stdout.softspace to 1. The space character wasn’t really printed until something else got printed on the same line. If the next print statement printed a carriage return, sys.stdout.softspace would be set to 0 and the space would never be printed. You probably never noticed the difference unless your application was sensitive to the presence or absence of trailing whitespace in print-generated output.) In Python 3, the way to do this is to pass end=' ' as a keyword argument to the print() function. The end argument defaults to '\n' (a carriage return), so overriding it will suppress the carriage return after printing the other arguments.
  6. In Python 2, you could redirect the output to a pipe — like sys.stderr — by using the >>pipe_name syntax. In Python 3, the way to do this is to pass the pipe in the file keyword argument. The file argument defaults to sys.stdout (standard out), so overriding it will output to a different pipe instead.