there is
list(set(some_list))
good way to remove duplicates from a list? (Python 3.3, if that matters)
(Edited to address some comments ... perhaps this was too brief before).
In particular,
, , , ; Pythonic .
, collections.OrderedDict set:
collections.OrderedDict
set
list(collections.OrderedDict((k, None) for k in some_list).keys())
, , itertools.groupby :
itertools.groupby
list(k for k,g in itertools.groupby(sorted(some_list)))
( , .)
Pythonic . Numpy, new_list = numpy.unique(some_list). " ", , , , - "Pythonic".
new_list = numpy.unique(some_list)
( Python 2.7):
>>> from collections import OrderedDict >>> list(OrderedDict.fromkeys('abracadabra')) ['a', 'b', 'r', 'c', 'd']
list(set(...)), .
list(set(...))
Source: https://habr.com/ru/post/1609745/More articles:DbGeography Intersects Method Doesn't Work - c #How to test screenshots of a view pager in Android using Espresso 2.2 - androidPHP - enter the name and class of the student in the corresponding name of the skill - htmlLinux server sending file to windows (Socket) client - c ++In Django, how can I inherit a model that is not abstract, as if it were abstract, so that I get one table in the database? - inheritanceNameResolutionFailure Nightmare: даже ModernHttpClient терпит неудачу - c#Reading an image from Excel and saving it in sqlserver - javaFatal error: Out of memory (1979711488 allocated) (attempt to allocate 131072 bytes) an error occurred while writing the xlsx file using phpexcel - phpIs Future required to perform calculations in a separate thread? - javaHow to print this class variable? - pythonAll Articles