Title: Signature.html
A three questions about askopenfilename and enumerate.

For askopenfilename:
1. Do I have to close the file before exiting from it?
2. How do I read each line of text in the file and quit when an eof is reached?

This certainly doesn't do it.

    def OpenConfigFile(self):
       
        config_file = askopenfilename( title="Open Configuration File",
                                    filetypes=CEN_FILE_TYPES )
        print "cfile-------: ",config_file, type(config_file)
        for it in config_file:
             config_file.readline(aline)
             print aline
        pass
        print "finished the file"

I get a "'str' object has no attribute 'readline'" msg trying to read a text file, Initial.sen, which is a text file and of type 'str'.

3. Where can I find out more about enumerate, as used here:
input_file=open('Initial.sen','r')
for (line_cnt, each_line) in enumerate(input_file):
    print each_line
input_file.close()
I used this small program for other purposes in the distant past, but what's going here with enumerate? Documentation for enumerate seems scarce.

BTW, is there a thorough document on the use of files in Python out there somewhere?
--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            
            Shhhh, quiet. I'm thinking about filling this space. 


                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to