__copy__
Dunder MethodPython 2.0+Advanced
Called by copy.copy() for shallow copying
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
class Example: def __copy__(self): return "Example __copy__" obj = Example() print(obj)
__copy__ called by copy.copy() for shallow copying. Implementing it lets you customize how Python interacts with your objects.
Try in PlaygroundTags
oopmagic-methodprotocolcore