What's wrong with this program

Bill Bell bill-bell at bill-bell.hamilton.on.ca
Tue Jul 3 19:04:48 EDT 2001


Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> wrote, in part:
> Does anyone have an example of how to set filename to access files in
> a directory list, so I can implement this?  My Python is limited, as I
> don't use it every day, and in limited ways.  Thanks. 

import glob
for filename in glob.glob('.\*'):
    print filename

Replace the argument to 'glob' with a string that gives the directory 
you want to list, and the 'print filename' with one or more 
statements making use of 'filename' that do whatever it is that you 
want to do.

Bill

> -----Original Message-----
> From: Oleg Broytmann [mailto:phd at phd.fep.ru]
> Sent: Tuesday, July 03, 2001 3:05 PM
> To: Kemp Randy-W18971
> Cc: 'python-list at python.org'
> Subject: RE: What's wrong with this program
> 
> 
> On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote:
> > Thanks for the correction.
> 
>    Actually I think you don't need ftp.connect() at all - it is called
> in ftp.__init__...
> 
> > Anyone know the correct format to transfer files
> > from one server directory to another server directory?
> 
>    I don't know - I've never used ftplib, but the idea is obvious: put
> it one by one. Something like this:
> 
> for filename in somelist:
>    ftp.storbinary("STOR " + filename, open(filename, 'rb'))
> 
> Oleg.
> ----
>      Oleg Broytmann            http://phd.pp.ru/           






More information about the Python-list mailing list