Hi
I want to create a generator function that supplies my calling function a file,
how though do I get the generator to accept attributes in the argument when
called?
This works not as a generator
for filename in sorted(file_list):
with open(dir_path + filename) as fd:
doc = xmltodict.parse(fd.read())
for item in doc['meeting']['race']:
for detail in item['nomination']:
print(item['@id'] + "\t" + detail['@id'] + "\t" +
detail['@number'] + "\t" + detail['@horse'])
And what I want to do is simplify
for detail in item['nomination']:
print(item['@id'] + "\t" + detail['@id'] + "\t" +
detail['@number'] + "\t" + detail['@horse'])
As I will have several implementations to do and would like to be able to
neatly handoff to sqlalchemy.
I have it as something like this but am not quite creating it correctly.
def return_files(file_list):
""" Take a list of files and return file when called
Calling function to supply attributes
"""
for filename in sorted(file_list, *attribs):
with open(dir_path + filename) as fd:
doc = xmltodict.parse(fd.read())
for item in doc([attribs]):
yield item
Thanks
Sayth
--
https://mail.python.org/mailman/listinfo/python-list