why the code error?

lunxian lunxian at yahoo.com
Sun May 19 22:50:05 EDT 2002


i'm a newbie of python. i encounter a problem in my programming.
here is my program. when it's running, a IOError always raised.
why? and how can i get more detail error message of the exception?


import os
import sys

def Parser(filename):
    lines = None
    try: 
        fsock = file("forparser.py","r",0)
        try: 
            lines = fsock.readlines() 
        finally: 
            fsock.close() 
    except IOError:
        print IOError.__str__
        return

    for line in lines:
        print line

if __name__ == "__main__":
    Parser("c:\forparser.py")



More information about the Python-list mailing list