Connect to FTP site with Python

I was recently having a complete nightmare connecting to a FTP site using the FileZilla client and wanted to write a quick Python script to test the connection myself. 

Thanks to the ftplib module that comes with Python, a simple test was possible in only four lines of code.

Here's an example:

from ftplib import FTP

ftp = FTP('hostname.goes.here')
ftp.login(user='username', passwd='password')

# Get a list of the directories on the FTP site to test the connection work

The console will then print the structure of the FTP site's root folder.