fork(1) download
  1. class MyList(list):
  2. def __mul__(self, other):
  3. if isinstance(other, MyList):
  4. return MyList((x,y) for x in self for y in other)
  5. else:
  6. return super().__mul__(self, other)
  7.  
  8. a = MyList([1, 2, 3])
  9. b = MyList([4, 5, 6, 7])
  10. print(a*b)
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
[(1, 4), (1, 5), (1, 6), (1, 7), (2, 4), (2, 5), (2, 6), (2, 7), (3, 4), (3, 5), (3, 6), (3, 7)]