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

list

tuple

set

frozenset

bag

frozen_bag

setlist

frozensetlist

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.

class collections_extended.Collection(Sized, Iterable, Container)

Bases: collections.abc.Sized, collections.abc.Iterable, collections.abc.Container

Collection abstract base class from collections.abc for Python >= 3.6 and backported to < 3.6