How to pass a list of files as a parameter in Python?

92 Views Asked by At

I'm working with the pyenchant spelling corrector and I'm trying to pass multiple files as a parameter in order to create a personal dictionary. I have 82 additional text files stored in a folder and I would like to pass them to the function without typing every single file name. Is that possible with Python? I've already tried creating a list of all the text files and then passing the list, but that didn't work. Here is my code:

import enchant
import os

allfiles = os.listdir("dicts")   

dictpwl = enchant.DictWithPWL("de_DE", allfiles)

This yields the following error:

AttributeError: 'list' object has no attribute '_request_dict_data'

Any suggestions on how to pass my text files in a different way? Thanks in advance!

0

There are 0 best solutions below