Eliminating an element in a for loop
I am trying to find the total size of the root directory on an FTP server. However, I don't have access to one of the directories in the root.
I want to use this function to sum the sizes of directories at the root:
size = 0
for filename in ftp.nlst("."):
ftp.cwd(filename)
size += ftp.size(".")
print(size)
This generates an error:
ftplib.error_perm: 550 Could not get file size.
I cannot find any documentation on excluding an element from a for loop.
+3
source to share