| 6 | import copy |
| 7 | |
| 8 | class My_Class: |
| 9 | |
| 10 | def __init__(self): |
| 11 | self.digits = [1, 2] |
| 12 | self.letters = ['x', 'y'] |
| 13 | |
| 14 | def custom_copy(self): |
| 15 | """ Copies 'digits' but shares 'letters'. """ |
| 16 | c = copy.copy(self) |
| 17 | c.digits = copy.copy(self.digits) |
| 18 | return c |
| 19 | |
| 20 | a = My_Class() |
| 21 | b = a.custom_copy() |