[Tutor] help

james middendorff james2dope@yahoo.com
Wed, 10 Oct 2001 16:05:31 -0700 (PDT)


--0-1370392546-1002755131=:9199
Content-Type: text/plain; charset=us-ascii


I have fixed my last post but I do have a question, I would like to keep looping this over and over until you type quit,thanks for the help!

import os, sys
try:
    while 1:
        filename = raw_input("whats the file?('quit' to quit)")
        if filename == 'quit':
            sys.exit()
           
        inp = open(filename, "r")
        for line in inp.readlines():
            print line
        inp.close()       
        
except IOError:
    print "Error: there is no file there!"


"I would kill everyone in this room
    for a drop of sweet beer."
     ----Homer Simpson----


---------------------------------
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
--0-1370392546-1002755131=:9199
Content-Type: text/html; charset=us-ascii

<P>I have fixed my last post but I do have a question, I would like to keep looping this over and over until you type quit,thanks for the help!</P>
<P>import os, sys<BR>try:<BR>&nbsp;&nbsp;&nbsp; while 1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename = raw_input("whats the file?('quit' to quit)")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if filename == 'quit':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sys.exit()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inp = open(filename, "r")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for line in inp.readlines():<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print line<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inp.close()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>except IOError:<BR>&nbsp;&nbsp;&nbsp; print "Error: there is no file there!"</P><BR><BR>"I would kill everyone in this room<br>    for a drop of sweet beer."<br>     ----Homer Simpson----<p><br><hr size=1><b>Do You Yahoo!?</b><br>
Make a great connection at <a
href="http://rd.yahoo.com/mktg/mail/txt/tagline/?http://personals.yahoo.com" target="_blank">Yahoo! Personals</a>.
--0-1370392546-1002755131=:9199--