fork(1) download
  1. class ExtendedString(str):
  2. def __init__(self, s):
  3. self.s = s
  4.  
  5. def __eq__(self, other):
  6. if len(self.s) > len(other.s):
  7. return other.s in self.s
  8. else:
  9. return self.s in other.s
  10.  
  11. def __ne__(self, other):
  12. if len(self.s) > len(other.s):
  13. return other.s not in self.s
  14. else:
  15. return self.s not in other.s
  16.  
  17. def __hash__(self):
  18. return super(str, self).__hash__()
  19.  
  20. list1 = ['Вася.пидор', 'Петя.гной', 'Маша.шлюха', 'Саша.блядь', 'пека', 'йоба']
  21. list2 = ['Вася', 'Петя', 'йоба']
  22.  
  23. es_list1 = [ExtendedString(s) for s in list1]
  24. es_list2 = [ExtendedString(s) for s in list2]
  25.  
  26. print(list1)
  27. print(list2)
  28. print([s for s in es_list1 if s not in es_list2])
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
['Вася.пидор', 'Петя.гной', 'Маша.шлюха', 'Саша.блядь', 'пека', 'йоба']
['Вася', 'Петя', 'йоба']
['Маша.шлюха', 'Саша.блядь', 'пека']