# WorkOrder.py # 3 ways to import objects to a class ## import ModuleName import datetime ## from ModuleName import ClassObjectName from datetime import date ## import ModuleName as Namespace import datetime as dt # Imports from Standard Modules # datetime, os, subprocess, etc... ## Datetime Module ## date class date with the time as zero time ## time class just time ## datetimeclass date and time from datetime import datetime ## timedelta class time differences / calculation import datetime # Chapter 6 # Imports from Custom Modules # Your filename.py python files # Inheritances page 60-63 # Allows the program to use a class aka. a child class (subclass or derived class) to inherit properties, attrs, methods, etc from another class ( known as a super class or base class ) WITHOUT having to redefine the props, attrs, methods, etc... # Base or Super Class class WorkOrder: def __init__(self, order_id, description): self.order_id = order_id self.description = description def base_display(self): print(f"Order ID and Description from base. Order id: {self.order_id}, Order Description: {self.description}.") # Subclass or derived class can either be defined in the same module.py or imports into another module.py class WorkOrder_Details(WorkOrder): def __init__(self, order_id, description, ship_priority): super().__init__(order_id, description) self.ship_priority = ship_priority def subclass_display(self): super().base_display() print(f"Subclass info for shipping: {self.ship_priority}.") # Chapter 6 Standard Modules DateTime Class page 67-68 # due date due_date = datetime.datetime(2024, 11, 16) print(due_date) formatted_due_date = due_date.strftime('%m/%d/%Y') print(formatted_due_date) # 11-16-2024 # ship date ship_date = datetime.datetime(2024, 11, 27) formatted_ship_date = ship_date.strftime('%m/%d/%Y') print(formatted_ship_date) # 11-27-2024 # invoice_due invoice_due = ship_date + datetime.timedelta(days=30) formatted_inv_date = invoice_due.strftime('%m/%d/%Y') print(formatted_inv_date) # 12-27-2024 # Output # The base or super class can either be used alone or with a subclass order1 = WorkOrder(1001, "Repair broken equipment") order1.base_display() print("-----------------------------------") # Ouput using both the super and the subclass with the data from the subclass order2 = WorkOrder_Details(1002, "Parts for repair workorder", "Same Day Shipping") order2.subclass_display() # a print() from base and a print() from sub class