Expanding a path of lists

I’m struggling with a good way to do this and wonder if there is a tried and tested method or a module that has this kind of capability? What I want to do is take something of the form:

/[Part1a, Part1b]/[Part2a, Part2b, Part2c]/[Part3a, Part3b]/

and expand it to all possible combinations, i.e.



The number of list members and path elements can vary. Any pointers?

1 Like

If only I’d studied a bit more maths when I was younger I would have known that what I was looking for was the “product” of these lists!

So I’ve found “itertools.product”

import itertools

parts = [
    ['Part1a', 'Part1b'],
    ['Part2a', 'Part2b', 'Part2c'],
    ['Part3a', 'Part3b']


I love Python :slight_smile: