Indentation error in Python 2.7
Question: I'm getting an indentation error in this line of code (it's a comment with all
spaces, no tabs), hope you can help me with this :)

    
    
    import os
    import socket
    import connection
    from constants import *
        """
        get_file_listing lists the files in the directory.
        """ # geting IndentationError: unexpected indent at this line's 5th column
        def get_file_listing(connection,):
            files = os.listdir(connection.directory)
            answer = str(CODE_OK) + " " + error_messages[CODE_OK] + EOL
            for f in files:
                path = os.path.join(connection.directory, f)
                if os.path.isfile(path):
                    answer += f + EOL
            answer += EOL
            return answer
    


Answer: You have 2 indentation errors. First one is your comment between """ """ tags.
It is normal string so it has to match indentation rules. Use # instead.
Second one is line where you define your function. It needs to match
indentation before.

    
    
    import os
    import socket
    import connection
    from constants import *
    """
    get_file_listing lists the files in the directory.
    """ # geting IndentationError: unexpected indent at this line's 5th column
    def get_file_listing(connection,):
        files = os.listdir(connection.directory)
        answer = str(CODE_OK) + " " + error_messages[CODE_OK] + EOL
        for f in files:
            path = os.path.join(connection.directory, f)
            if os.path.isfile(path):
                answer += f + EOL
        answer += EOL
        return answer
    

