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'):
self.encoding = encoding
self.source_address = source_address
self.timeout = timeout
if host:
self.connect(host, port)
if user:
self.login(user, passwd, acct)
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
If the port parameter would be added, I could use it like this:
with FTP(host, port, user, password) as ftp:
# my actions
In all my cases, all I need is to connect to ftp server and work with it. If there is some trouble with connection or login, the code still can’t continue working with ftp…
Do you rather use connect() and login() explicitly or just let it connect and login within __init__ implicitly? What do you think about it?
Thanks.