possible ftplib bug

Andrew Dalke adalke at mindspring.com
Sat Jan 11 18:32:37 EST 2003


Dagur Páll Ammendrup wrote:
> When I connect to my site using FTP('my site') it works but when I do 
> FTP('my site',21)  or FTP('my site','21') it doesn't. Is this a bug in 
> ftplib?

Here's what 'FTP' takes as parameters

class FTP([host[, user[, passwd[, acct]]]])

Using '21' or 21 sets the 'user' field and not the port.

It looks like you can set the port using the 'connect' method
of the FTP object

    connect(host[, port])
     Connect to the given host and port. The default port number is
     21, as specified by the FTP protocol specification. It is
     rarely needed to specify a different port number. This
     function should be called only once for each instance; it
     should not be called at all if a host was given when the
     instance was created. All other methods can only be used after
      a connection has been made.

So try

server = FTP()
server.connect('my site' 21)

WARNING: I have not tested this myself.

and I too think the interface is counterintuitive.

					Andrew
					dalke at dalkescientific.com





More information about the Python-list mailing list