Nov-10-2020, 10:32 AM
I often use the fact, that a dict is a set without values, but since Python 3.6 the order is preserved.
So using
So using
list(dict.fromkey(iterable))
will keep the order from the original iterable, but will remove duplicates.from ipaddress import ip_address spam = [ip_address('192.168.0.1'), ip_address('192.168.0.2'), ip_address('192.168.0.1')] unique_preserved_order = list(dict.fromkeys(spam))
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!