1>>> import copy
2>>> a = 0
3>>> b = 2
4>>> a = copy.copy(b)
5>>> b += 1
6>>> a
72
8>>> b
93
1class Foo:
2 def __init__(self, orig=None):
3 if orig is None:
4 self.non_copy_constructor()
5 else:
6 self.copy_constructor(orig)
7 def non_copy_constructor(self):
8 # do the non-copy constructor stuff
9 def copy_constructor(self, orig):
10 # do the copy constructor
11
12a=Foo() # this will call the non-copy constructor
13b=Foo(a) # this will call the copy constructor