call function example 3
This commit is contained in:
parent
504135cd93
commit
63dbcd0922
13
python-temel/call.function.3.py
Normal file
13
python-temel/call.function.3.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
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)
|
Loading…
Reference in New Issue
Block a user