[Tutor] Ftplib Error
John Weller
john at johnweller.co.uk
Sat Jan 2 11:27:28 EST 2021
I use the following code to download a list of files from a web server:
try:
ftp = ftplib.FTP(data.ftp_host) # connect to host, default port
ftp.login(user=data.ftp_user <ftp://ftp.login(user=data.ftp_user> , passwd=data.ftp_passwd)
except ftplib.all_errors as err:
# Log the error
logging.error(err)
else:
ftp.cwd(data.ftp_dir) <ftp://ftp.cwd(data.ftp_dir)>
files = ftp.nlst() <ftp://ftp.nlst()>
I am using VS Code and have just installed Pylance. It is now telling me that “all_errors” is not a valid exception class but the documentation suggests that it is unless I am mis-reading the documentation (always a possibility 😊). Your advice will be gratefully received.
John
John Weller
07976 393631
More information about the Tutor
mailing list