Set Methods

set.copy()

Build a separate outer set with the same element references. Changes to membership in either set do not affect the other. The method is shallow, so user-defined hashable objects are not recursively cloned. Do not change the hash or equality behavior of an object while it is a member.

Formal Syntax & Structure

python syntaxpython
items.copy()

Return Value

set

Shallow copy with equal members.

Working Example

Example Snippetpython
original = {"draft", "review"}clone = original.copy()clone.add("done")print(sorted(original))print(sorted(clone), clone is original)
Python Reference