/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
get_unique_items__with_ordered.py
20 строк
416 B
gil9red
Refactoring. Using black code style
24 июн 2023, 13:06
24 июн 2023, 13:06
dcf6e14
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" from collections import OrderedDict # pip install more_itertools from more_itertools import unique_everseen items = [1, 2, 0, 1, 3, 2] seen = set() print([x for x in items if x not in seen and not seen.add(x)]) # [1, 2, 0, 3] print(list(OrderedDict.fromkeys(items))) # [1, 2, 0, 3] print(list(unique_everseen(items))) # [1, 2, 0, 3]