please explain foreach

Comments

1 comment

  • Avatar
    DevHopeful_2012

    I believe the foreach in the example works with a list of lists because the return value of registryFind is a list and findall is set to true. Therefore, the foreach will iterate over the list, ${installedApplications}, but each element in the list is a list, itself. The example cleverly parses the list element by specifying a variable for each index. Something similar to the following:

    installedApps = [('Notepad++', 'DisplayName', 'Notepad++'), ('Office14.STANDARD', 'DisplayName', 'Microsoft Office Standard 2010')]
    for (key, name, value) in installedApps:
        print "Found Registry Entry:\\n\\tkey: %s\\n\\tname: %s\\n\\tvalue: %s" % (key, name, value)
    

    Found Registry Entry:
        key: Notepad++
        name: DisplayName
        value: Notepad++
    Found Registry Entry:
        key: Office14.STANDARD
        name: DisplayName
        value: Microsoft Office Standard 2010
    

Please sign in to leave a comment.