Standard Module ftplib

ftplib

This module defines the class FTP and a few related items. The FTP class implements the client side of the FTP protocol. You can use this to write Python programs that perform a variety of automated FTP jobs, such as mirroring other ftp servers. It is also used by the module urllib to handle URLs that use FTP. For more information on FTP (File Transfer Protocol), see Internet RFC 959.

Here's a sample session using the ftplib module:

>>> from ftplib import FTP
>>> ftp = FTP('ftp.cwi.nl')   # connect to host, default port
>>> ftp.login()               # user anonymous, passwd user@hostname
>>> ftp.retrlines('LIST')     # list directory contents
total 24418
drwxrwsr-x   5 ftp-usr  pdmaint     1536 Mar 20 09:48 .
dr-xr-srwt 105 ftp-usr  pdmaint     1536 Mar 21 14:32 ..
-rw-r--r--   1 ftp-usr  pdmaint     5305 Mar 20 09:48 INDEX
 .
 .
 .
>>> ftp.quit()

The module defines the following items:


\begin{funcdesc}{FTP}{\optional{host\optional{\, user\, passwd\, acct}}}
Return ...
...sswd} and \var{acct} default to the empty string when not given).
\end{funcdesc}


\begin{datadesc}{all_errors}
The set of all exceptions (as a tuple) that methods...
...s listed below as well as
\code{socket.error} and \code{IOError}.
\end{datadesc}


\begin{excdesc}{error_reply}
Exception raised when an unexpected reply is received from the server.
\end{excdesc}


\begin{excdesc}{error_temp}
Exception raised when an error code in the range 400--499 is received.
\end{excdesc}


\begin{excdesc}{error_perm}
Exception raised when an error code in the range 500--599 is received.
\end{excdesc}


\begin{excdesc}{error_proto}
Exception raised when a reply is received from the server that does
not begin with a digit in the range 1--5.
\end{excdesc}



Subsections