-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecial.py
62 lines (43 loc) · 833 Bytes
/
special.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class student:
def __init__(self, name):
self.name = name
def __str__(self):
return 'student : name = %s' % self.name
__repr__ = __str__
def __getattr__(self, attr):
if attr == 'score':
return 'zjtioi2019ak'
def __call__(self):
print("zjt ioi ak")
a = student('zjtioiak')
print(a)
print(a.score)
a()
class fib:
def __init__(self):
self.a, self.b = 0, 1
def __iter__(self):
return self
def __next__(self):
self.a, self.b = self.b, self.a + self.b
if(self.a > 10000):
raise StopIteration()
return self.a
def __getitem__(self, n):
a, b = 1, 1
for x in range(n):
a, b = b, a+b
return a
'''
for n in fib():
print(n)
for n in fib():
print(type(n))
print(isinstance(n, int))
print(isinstance(n, fib))
'''
'''
f = fib()
for n in range(10):
print(f[n])
'''