Steaming PDF from Python Script to IE

Erik Max Francis max at alcyone.com
Sat Jun 21 22:15:24 EDT 2003


Stephen Thorne wrote:

> What you probably want is actually
> 
> print 'Content-Type: application/pdf\r\n\r\n',
> print out,
> 
> the ',' at the end of the line supresses lineendings. Also windows
> likes
> \r\n for CRLF, whereas you were just sending LF (which is sufficient
> for
> unixes).

If you want precise control over newlines and spaces in output, using a
print statement of almost any form is a bad example.  This is a
particularly good example, since what you suggest as it stands won't
work:

>>> print 'test',; print 'ing',
test ing

Note the space; by default print without the comma at the end prints a
newline, and with a comma at the end prints a _space_ instead.  This can
be changed through other means, but a much better (and quite frankly,
less ugly) approach is to use sys.stdout.write directly:'

>>> sys.stdout.write('test'); sys.stdout.write('ing')
testing

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Eppur, si muove!  (But still it moves!)
\__/  Galileo Galilei




More information about the Python-list mailing list