Pythonic would mean using the tools available.
Use the csv
module to read the comma separated line:
with open('cars.txt') as cars_file:
cars = next(csv.reader(cars_file))
with open('colors.txt') as colors_file:
colors = next(csv.reader(colors_file))
Use itertools.product
to create the Cartesian product:
from itertools import product
In Python 3.x:
for car, color in product(cars, colors):
print(car, color)
In Python 2.7:
for car, color in product(cars, colors):
print car, color
In one line:
print('\n'.join('{car} {color}'
.format(car=car, color=color)
for car, color in product(cars, colors)))