python-CSD-kursu/python-temel/call.function.3.py

14 lines
189 B
Python

class Sample:
def __init__(self, n):
self.n = n
def __call__(self, x):
return x ** self.n
s = Sample(3)
result = map(s, range(10))
for x in result:
print(x)