-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_inheritance.py
executable file
·55 lines (44 loc) · 1.07 KB
/
class_inheritance.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
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import sys
class item_master():
def __init__(
self,
item,
price
):
self.item = str(item).strip()
self.price = price
def __str__(self):
return ('{} = {}'.format(
self.item,
self.price,
))
class item_detail(item_master):
def __init__(
self,
item,
price,
desc
):
a.__init__(self, item, price)
self.desc = str(desc).strip()
def main():
x=item_master('A1500', 2.50)
print(x)
# A1500 = 2.5
y=item_detail('B2700', 3.5, 'Water soluble')
print(y)
# this runs item_master's __str__.
# B2700 = 3.5
if __name__=='__main__':
# logger setup
logfile = str(sys.argv[0])[:-3] + '.log'
logging.basicConfig(
filename = logfile,
format = '%(asctime)s - %(filename)s: %(lineno)s: %(funcName)s - %(levelname)s: %(message)s',
# level = logging.DEBUG,
level = logging.ERROR,
)
main()