python copy class instance code example
Example 1: python copy instance
import copy
class A(object):
def __init__(self, a)
self.a = a
a = A(38)
# Deepcopy
a2 = copy.deepcopy(a)
# Shallow copy -> use this if copy.deepcopy() fails
a3 = copy.copy(a)
Example 2: call instance class python
# define class
class example:
# define __call__ function
def __call__(self):
print("It worked!")
# create instance
g = example()
# when attempting to call instance of class it will call the __class method
g()
# prints It worked!
Example 3: create instance object java
myCar = new Car();