[Tutor] about counting files
Tue Apr 29 15:25:02 2003
On Mon, 28 Apr 2003, Abdirizak abdi wrote:
> Hi, can ayone help me with this program, I am reading multiple files and
> I want to count each of these files, I tried different things but I
> couldn't get it right.
Can you tell us in more detail what you expect, and what things look ok?
Have you been able to get the counting working with a single file first?
The main loop that you've written,
if __name__ == '__main__':
for arg in sys.argv[1:]:
looks somewhat ok, but the code doesn't tell us what it will do with all
these file arguments.
The file opening code in genIndex() looks a little odd:
def genIndex(indexFileName, extension):
for line in fileinput.input(glob.glob(fname)):
Where does indexFileName get used? I see that it's used to control the
name of the shelf we open,
> shelf = shelve.open(indexFileName,'n')
But if we give the program a set of parameters, like 'a b c', I think the
code will trying to write three duplicate index files of all the text
files in the current directory. Is this what you want?
Talk to you later!