Python Set - copy method

Method Name:

copy()

Method Overview:

The copy() method returns a copy the set. The copy returned is a shallow copy.
i.e., A new set object is created and the elements are copied from the source set.
The elements are not created afresh.They are just referred.

Return Value:

Returns a shallow copy of the original set.

Exception Handling:

None

Example:
 

>>> PrinterQueue = {'Job1',"Job2","Job3","Job4","Job5"}

>>> BackupQueue  = PrinterQueue.copy()

>>> print(BackupQueue)

{'Job3', 'Job2', 'Job4', 'Job1', 'Job5'}


Copyright 2024 © pythontic.com