[Tutor] File copying - best way?

fleet@teachout.org fleet@teachout.org
Sun, 5 Aug 2001 08:47:00 -0400 (EDT)


On Sat, 4 Aug 2001, Danny Yoo wrote:

> > >From a beginner's perspective, I'm finding this constant ongoing discovery
> > of additional modules a little disconcerting.  For a 24-line (so far)
> > shell script, I now have 5 modules to import.  (And if I remove the "try"
> > tests, only 8 lines!) Is there a list somewhere that breaks the modules
> > down into categories such as "file handling" (and that includes ALL the
> > modules pertaining to file handling)?
>
> You might find:
>
>     http://www.python.org/doc/current/lib/lib.html
>
> what you're looking for.  It's organized in a nice, large, disconcerting
> table of contents.  *grin*

Well, it *is* disconcerting.  Using 'glob' in the browser "find" function,
I find grouped together:

        6.18 getopt -- Parser for command line options
        6.19 tempfile -- Generate temporary file names
        6.20 errno -- Standard errno system symbols
        6.21 glob -- Unix style pathname pattern expansion
        6.22 fnmatch -- Unix filename pattern matching
        6.23 shutil -- High-level file operations

and three of the six actually contain the word 'file' in the description.
Missing are "stat" (and it's close kin), "os", "fileinput", "xreadlines",
"filecmp", "popen2" (and 3 and 4??), and maybe "mmap".

"getopt" and "tempfile" don't do much for me right at the moment.
"fnmatch" is a mystery and there's no example.  (The narrative mentions
glob() uses fnmatch() - so I'm probably better off with "glob".  "glob"
and "shutil" I will find useful.  I think I might find "errno" useful also
- but I have no clue how to use it.  Would this have allowed me to test:

os.popen("ls *.jpg")

if it found no jpg files?

					- fleet -