Title: Signature.html


bob gailer wrote:
Wayne Watson wrote:
I have a Python application that requires the program be run in a specific folder, Win XP. It analyzes and modifies txt files there, and only txt files. The mods require creating a tmp file. The tmp files could just as well be an xyz suffix file.  That is, it seems as though they could be almost any non-conflicting type with hundreds of file types in use. There may be other file types in the folder, possibly jpg.   As such, why would I want to use the tmp files module?

With a similar program, it requires reading through all txt files, among other files types, in the folder. It purely analyzes the data in the txt files. Is there some way of doing the reading without the use of os.listdir()?

I'm finding it a little hard to grok your question / concern.

One does not use os.listdir() to read files. One opens them then uses read or readline.

There are many ways to get and filter directory contents.

I guess you would benefit from the glob module.

import glob
fileList = glob.glob('*.txt')

grok. An interesting word. I guess it means understand. Surprisingly the Mozilla spell checker OKed it.

Anyway, I'm finally back. About one hour after posting this message, my c-drive. Amazingly I got it back up.

Yes, listdir does not read files, it just prepares a list of all files in the folder. I work my way through them as needed. It looks like glob does something similar.

The real question is about tmp files. I believe there's a tmpfiles module. Someone back a few weeks ago noted in a post I made that I was using a tmp suffix and suggested using tmpfiles. In my case, I don't see the need. What is the tmpfiles module going to do for me? What's so special about the tmp suffix?
--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            
           "Truth is mighty and will prevail. There is nothing wrong
            with this, except that it ain't so."   -- Mark Twain
            
                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to