python class object as argument code example
Example 1: variable number of arguments to python class
def multiply(*args):
z = 1
for num in args:
z *= num
print(z)
multiply(4, 5)
multiply(10, 9)
multiply(2, 3, 4)
multiply(3, 5, 10, 6)
Example 2: python pass class as argument
class a():
def __init__(self):
print "an object from class a is created"
def hello(the_argument):
x = the_argument()
hello(a)
Output:
an object from class a is created