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')

--
Bob Gailer
Chapel Hill NC 919-636-4239

When we take the time to be aware of our feelings and needs we have more satisfying interatctions with others.

Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to