Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
oorrja
GitHub Repository: oorrja/learntosolveit
Path: blob/master/languages/python/design_python3_meta_ex1.py
1240 views
1
class mymeta(type):
2
def __new__(cls, name, bases, dict):
3
print(("Creating name:", name))
4
print(("Base Classes:", bases))
5
print(("Class Body:", dict))
6
# create the actual class object
7
return type.__new__(cls, name, bases, dict)
8
9
class Rectangle(object, metaclass=mymeta):
10
def __init__(self, width, height):
11
self.width = width
12
self.height = height
13
14
def area(self):
15
return self.width * self.height
16
17
def perimeter(self):
18
return 2*self.width + 2* self.height
19
20