Collection Methods

collections.deque.copy()

Return a shallow copy preserving the bound and sharing references to nested items.

Formal Syntax & Structure

python syntaxpython
deque_instance.copy()

Return Value

deque

The deque result described above.

Working Example

Example Snippetpython
import collectionsd=collections.deque([[1]],maxlen=2)c=d.copy()c.append([2])print((list(d),list(c)))
Python Reference