[Tutor] Newbie in Python (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Mar 14 03:03:44 CET 2005


On Sun, 13 Mar 2005, Danny Yoo wrote:

> Thanks for the reply..i wasn't sure how this works so I am glad there is
> someone that might be able to help me.  Because this is an university
> assignment I am not sure how much of help you can provide..but here it
> goes.

[text cut]

As you might understand, we won't do homework.  We'll try to point you
toward things that will help, but otherwise, our help will be very
restricted.


[homework problem statement cut]

I'll pretend that I did not read that problem statement, since most of it
is pretty much off-limits to us as Python-Tutors, and irrelevant to the
question that you have given us.


Let's get straight to your question.

> ---I am stuck in understanding how I can go about opening the
> folder(directory) that contains all the files that I need to process for
> this assignment.  As the folder contains sub folders ie and then the
> email files that need to be processed.

You may want to look at the 'os' module,

    http://www.python.org/doc/lib/module-os.html

as it includes functions that deal with operating systems and directory
managment.  In particular, you may want to experiment with os.walk():

    http://www.python.org/doc/lib/os-file-dir.html#l2h-1617

Other functions like os.chdir() or os.listdir() might also be useful to
you, as well as the utility functions in os.path:

    http://www.python.org/doc/lib/module-os.path.html

I suspect, though, that os.walk() should do the trick.


If you have more questions, please feel free to ask.  But don't just
copy-and-paste problem statements from your homework: we will actively try
to ignore those.  We're much more interested in the questions that you
have.



More information about the Tutor mailing list