the following code is returning some strange indentation error inside a for statement. The console is pointing the error at a list.append() method. It should be a silly misstake onetime I am new at Python. heh
import os
import sys
import re
import globfrom Text import Text
from Word import Word
from FileCategory import FileCategoryclass FileIO(object):def loadFile(self, filePath):newText = Text(os.path.basename(filePath))words=[]with open(filePath) as buff:content = buff.read().lower()re.sub("[^\w\s]", "", content)re.sub("[0-9]", "", content)words = content.Split(' ')for word in words:wordFound = next(auxWord for auxWord in newText.words if auxWord.textWord == word) if wordFound is None:newWord = Word(word, 1)newText.words.append(newWord)else:wordFound.countInText+=1return newTextdef loadFilesFromDirectory(self, path):newCategory = FileCategory()files=[]os.chdir(path)for file in glob.glob("*.txt"): files.append(file)for filePath in files:newFile = loadFile(filePath)if newFile is not None:newCategory.files.append(newFile)return newCategory
Log:
Traceback (most recent call last):File "aprendizadMaq.py", line 6, in <module>from FileIO import FileIOFile "/home/adolfosrs/Dropbox/7º Semestre/IA/T2/pyAprendizadMaq/FileIO.py", line 38files.append(file)^
IndentationError: expected an indented block
Any Idea?