Internet Explorer and Python/XML/HTML
Posted 6 Oct 2005 by herman

Internet Explorer (if you use that) does not correctly display or download some of the Python/XML or HTML examples.

I found an explanation of this phenomenon here: Content-type: text/plain. It seems that IE is just "too smart" -- when it gets content that might be HTML, it treats that content as HTML, even when the web server states that the content type is plain text. So, if I make a Python program or a text file that contains some amount of XML or HTML-looking data somewhere (like in a string of a Python program), then IE will display it as if it had been HTML, which loses the important Python indentation!

How to get around this? I'm open to suggestions. The only thing I was able to do, after downloading to my Windows desktop, was to open a command shell and rename the file to "xml-cleanup.py" using an old-fashioned Windows command. After that, the ".py" suffix let my Python editor open it up and run it.


A Short Demonstration, posted 7 Oct 2005 by herman
Here's a demonstration of the problem. The file limerick-a.txt displays properly as a text file; the second word in the file is the string HTML. Now look at the same file, but with "<" and ">" surrounding the string HTML: limerick-b.txt. The entire string vanishes and text wraps around, losing intendation and newline characters, because IE treats the file as HTML!!
Student Suggestions, posted 8 Oct 2005 by herman
Students offered the following advice for the problem.

Home PageHelp PageView ArticlesView Public DocumentsLogin, do stuff (record diaries)List Group MembersList of Projects