How to copy an object in Python

You can copy an object in Python using deepcopy :

The "=" does is to assign another reference to the same object in memory . The deepcopy creates a whole new object in memory with the values of A and B will reference it. You can test it using the following:

Above program output same Ids

Above program output different Ids
 (C) 2022    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About