__deepcopy__

Dunder MethodPython 2.0+Advanced

Called by copy.deepcopy() for deep copying

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
class Example:
    def __deepcopy__(self):
        return "Example __deepcopy__"

obj = Example()
print(obj)

__deepcopy__ called by copy.deepcopy() for deep copying. Implementing it lets you customize how Python interacts with your objects.

Try in Playground

Tags

oopmagic-methodprotocolcore