generator function - Called and accepts XML attributes- Python 3.5

Sayth Renshaw flebber.crue at gmail.com
Sat Sep 10 23:23:09 EDT 2016


This seems to work as a starter.

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):
        with open(dir_path + filename) as fd:
            doc = xmltodict.parse(fd.read())
            for item in doc['meeting']['race']:
                yield item


my_generator = return_files(file_list)

def gets_id():
    for value in my_generator:
        for asset in value['nomination']:
            print(asset['@id'])
        
gets_id()

Cheers

Sayth




More information about the Python-list mailing list