Jun-22-2018, 02:51 AM
I have the following
Example:
namedtuple
and List
from collections import namedtuple firefoxprofile = namedtuple("Profile", ["Name", "Path", "isRelative", "Default"]) jb = firefoxprofile(Name='Jason', Path='Profiles/er5rtak4.Jason', isRelative='1', Default=None) sr = firefoxprofile(Name='Sarah', Path='Profiles/23mvfqcj.Sarah', isRelative='1', Default=None) files = ["places.sqlite","key4.db", "logins.json"] firefoxlisttuple = [] firefoxlisttuple.append(jb) firefoxlisttuple.append(sr)I'm using a nested for loop to create the paths to each of the files in the files List.
Example:
for profile in firefoxlisttuple: for file in files: print("{0}\{1}".format(profile.Path,file))Output:
Profiles/er5rtak4.Jason/places.sqlite Profiles/er5rtak4.Jason/key4.db Profiles/er5rtak4.Jason/logins.json Profiles/23mvfqcj.Sarah/places.sqlite Profiles/23mvfqcj.Sarah/key4.db Profiles/23mvfqcj.Sarah/logins.jsonI'm aware that a nested for loop isn't a good idea in terms of preformace. What should I do instead to achieve the same output?