
Marty writes:
If there is possible to connect and login to ftp server within __init__, I think it would make sense to add parameter **port** in ftplib.FTP. It could look like this: ``` def __init__(self, host='', port=0, user='', passwd='', acct='', timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None, *, encoding='utf-8'): [...] (Or port parameter could be added at the end of the __init__ parameters not to break current logic.)
I think that last comment is right. In calls you can put it in the natural (host, port, user, password) order using keywords. Another possibility would be to overload 'host' to accept 'HOST:PORT' or even 'USER:PASSWORD@HOST:PORT'.
Currently if I need to specify port, I have to do it like this: ``` with FTP() as ftp: ftp.connect(host, port) ftp.login(user, password) # my actions
To be honest, I really don't think that's so burdensome. In your own code, you could just wrap it in your own class that DTRTs, using any or all of the above extensions: with MyFTP('example.com', 8042, 'me', 'apocryphum') as ftp: # my actions with MyFTP('example.com:8042', 'me', 'apocryphum') as ftp: # my actions with MyFTP('me:apocryphum@example.com:8042') as ftp: # my actions