You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is:
# File: ftplib-example-1.py import ftplib f
Try to use ftp.nlst(dir).
However, note that if the folder is empty, it might throw an error:
files = [] try: files = ftp.nlst() except ftplib.error_perm, resp: if str(resp) == "550 No files found": print "No files in this directory" else: raise for f in files: print f