for loop iter next if file bad
Joaquin.Alzola at lebara.com
Wed Dec 21 04:55:45 EST 2016
> Take a list of files and return file when called.
> Calling function to supply attributes
> for file in file_list:
> with open(os.path.join(dir_path, file), 'rb') as fd:
> if os.stat(fd.name).st_size == 0:
> yield fd
>Exact error is:
>C:\Users\Sayth\Anaconda3\envs\race\python.exe C:/Users/Sayth/PycharmProjects/bs4race/race.py data/ -e *.xml
>Traceback (most recent call last):
> File "C:/Users/Sayth/PycharmProjects/bs4race/race.py", line 98, in <module>
> File "C:/Users/Sayth/PycharmProjects/bs4race/race.py", line 51, in data_attr
> for xml_data in roots:
> File "C:/Users/Sayth/PycharmProjects/bs4race/race.py", line 32, in return_files
>TypeError: 'str' object is not an iterator
The iterator is file_list not file.
File is a str. As the exception mentions.
I suppose you want there a "continue" to iterate to the next value in the file_list
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.
More information about the Python-list