1from typing
import Union, Callable, Iterable, Literal
5def drop_duplicates(iterable, method:Literal[
'set',
'sorted set',
'generator',
'manual',
'other']=
'sorted set'):
6 method = method.lower()
8 return type(iterable)(set(iterable))
9 elif method ==
'sorted set':
10 return list(sorted(set(iterable), key=
lambda x: iterable.index(x)))
11 elif method ==
'generator':
17 elif method ==
'manual':
21 if x[
'link']
not in dups:
23 dups[x[
'link']] =
None
24 elif method ==
'other':
26 for index
in len(biglist):
27 link = biglist[index][
'link']
28 if link
in seen_links:
32 raise ValueError(f
'Unknown method {method}. Options are: (set, sorted set, generator, manual, other)')
36 """ Basically the same thing as Dict.update(), except returns a copy
37 (and can take multiple parameters)
46 """ Exactly the same thing as a regular dict, except you can get and set multiple items
47 at once, and it returns a list of the asked
for items,
or sets all of the items to
50 def __getitem__(self, *keys):
52 raise KeyError(
"No input parameters given")
53 return [super().__getitem__(key)
for key
in keys]
55 def __setitem__(self, *keys, value):
Exactly the same thing as a regular dict, except you can get and set multiple items at once,...