fork download
  1. import itertools
  2.  
  3.  
  4. def yoba(data, eq):
  5.  
  6. ndata = []
  7. for v in data:
  8.  
  9. if not any(map(eq, itertools.repeat(v), ndata)):
  10.  
  11. ndata.append(v)
  12.  
  13. return ndata
  14.  
  15. data = (1, 1.0, 1.0 + 0.0, "1", 2, 2, 2, 1, 2 ** 16, 2 ** 16 + 0)
  16. print(yoba(data, lambda a, b: a == b))
  17. print(yoba(data, lambda a, b: a is b))
  18. print(yoba(data, lambda a, b: a == b and type(a) is type(b)))
  19.  
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
[1, '1', 2, 65536]
[1, 1.0, 1.0, '1', 2, 65536, 65536]
[1, 1.0, '1', 2, 65536]