An FTP Client...My first real program!

Python Nutter pythonnutter at gmail.com
Thu Aug 14 05:53:06 CEST 2008


sorry cut off due to original email being sent not to the list due to gmail:

A second for that suggestion--the ftp module in the python standard library is
very low level and not very useful for beginners as a lot of the heavy
lifting and management is still left up to you, the programmer.

2008/8/14 Python Nutter <pythonnutter at gmail.com>:
> ery low level and not very useful for beginners as a lot of the heavy
> lifting and management is still left up to you, the programmer.
>
> The module ftputil is a high-level interface to the ftplib module. The
> FTPHost objects generated from it allow many operations similar to
> those of os and os.path. An example:
>
> # download some files from the login directory
> host = ftputil.FTPHost('ftp.domain.com', 'user', 'secret')
> names = host.listdir(host.curdir)
> for name in names:
>   if host.path.isfile(name):
>       host.download(name, name, 'b')  # remote, local, binary mode
> # make a new directory and copy a remote file into it
> host.mkdir('newdir')
> source = host.file('index.html', 'r')  # file-like object
> target = host.file('newdir/index.html', 'w')  # file-like object
> host.copyfileobj(source, target)  # similar to shutil.copyfileobj
> source.close()
> target.close()
>
>
> Now if you are again purely in it for a challenge or for and
> educational roller coaster ride, ignore the suggestion to look at
> higher level ftp modules =)
>
> Cheers,
> PN
>



More information about the Python-list mailing list