>>247
itertoolsのcartesian_productがほぼそれ