-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecorators.py
More file actions
78 lines (65 loc) · 1.59 KB
/
decorators.py
File metadata and controls
78 lines (65 loc) · 1.59 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""how to creat yhe decorators"""
# def mydecorators (func):
# def wrapper():
# print("befor function run")
# func()
# print("after function run")
# return wrapper
# @mydecorators
# def say_hello():
# print("hello")
# say_hello
""""abstractmethod"""
# from abc import abstractmethod , ABC
# class shape(ABC):
# @abstractmethod
# def area(self):
# pass
# class triangle(shape):
# def area(self,a,b,c):
# self.a= a
# self.b = b
# self.c = c
# print(self.a*self.b*self.c)
# class rectangular(shape):
# def area(self,a,b):
# self.a=a
# self.b=b
# print(self.a*self.b)
# obj = triangle()
# obj.area(90,20,10)
"""starticemethod"""
# class c1:
# data =90
# @staticmethod
# def m1():
# a=90
# b=10
# print(a+b)
# c1.data=89
# print(c1.data)
# print("i am m1 from staticemethod")
# obj=c1()
# obj.m1()
"""classmethod"""
'''class method is a method which is bounded to the class rather then its instance'''
# class c1:
# data =90
# @classmethod
# def m1(cls):
# cls.data ="data new"
# cls.a =100
# print (cls.data)
# obj=c1()
# obj.m1()
# print(c1.a)
"""generator"""
'''it is a 'less Memory Efficiency': and 'lazy evaluation' and 'simple functon' and 'use return' and infinite data set . '''
# def gen():
# yield 1
# yield 2
# yield 3
# data = gen()
# print(next(data))
# print(next(data))
# print(next(data))