Collection Factory¶
collections_extended also provides a collection factory. Combining Python’s standard collections with bags and setlists allows you to create a collection with any combination of ordered, unique and mutable.
Collection |
Mutable |
Ordered |
Unique |
---|---|---|---|
|
✔ |
✔ |
|
|
✔ |
||
|
✔ |
✔ |
|
|
✔ |
||
✔ |
|||
|
|||
✔ |
✔ |
✔ |
|
✔ |
✔ |
API¶
-
collections_extended.
collection
(iterable=None, mutable=True, ordered=False, unique=False)[source]¶ Return a
Collection
with the specified properties.- Parameters
iterable (Iterable) – collection to instantiate new collection from.
mutable (bool) – Whether or not the new collection is mutable.
ordered (bool) – Whether or not the new collection is ordered.
unique (bool) – Whether or not the new collection contains only unique values.
Collection abstract base class from
collections.abc
for Python >= 3.6 and backported to < 3.6