I have the following 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.json
I'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?
I've looked into these links:
Iterate over two lists with different lengths
Python merging two lists with all possible permutations
but I'm not sure if it's the correct approach. Is permutations
the right tool for this task?