I have a function like this. For *args I want to use a list of different Excel tables.
def my_function(*args):
for x in args:
# some code
I use this to get the full paths to the tables and make a list of them. There are only tables in the folder I want to use.
cust_tables = os.listdir(r"my_folder")
cust_path = [r"my_folder" + "\\" + x for x in cust_tables]
This creates a list like this:
['C:\\some\\path\\to\\my\\table_1.xlsx', 'C:\\some\\path\\to\\my\\table_2.xlsx']
When I try to call the function my_function(cust_path)
, I get this error:
File "C:\Users\my.name\AppData\Local\Continuum\anaconda3\lib\genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not list
I can call the function when using my_function(cust_path[0],cust_path[1])
.
Where did I make a mistake?