XPYM301207 InstructorPhilipM-1 10 E - 1 E 1 E - 1:45 E Lunch 1:45 E - 4:45 E Visual Studio Code OOP Application Factory > Container / Store Token / Storage PROVIDER > API / INPUTS > providing to a class Services > Injectables / Web Services / HTTPS Class > template to create objects 1. class definition > class keyword name 2. attributes / Property > "meta" "variables that hold data" "instance variables" "fields" "cols" 3. method > function that returns to "seomthing else" 4. Constructor > __init__ method > "construct data" 5. Object Instance > obj_name = Class() Object property > var name and type fname as string value > Philip return self.fname > from yourself first_name this.fname = first_name this.fname > something else print("Name: " , fname) object print("Name: " + fname) property print(f"Name: {fname}) view assign value to a property fname = "Philip" break 11:35 E - 11:50 E page 56 string method f"" Page 60 Inheritance OOP principle superclasses super() and subclasses in python parent classs and child classes overrides / overloads injectables Product Master Discount Schedule class Product class Discount Product() + disc% class Inventory Product() + invAsset, invQty class PurchaseOrder Product() + vendorid, qty, bo class Order class OrderDetails Order() + qty, custom1 .10 10 / 100 25 value assigned value > arg discount passed arg to > parameter discount parameter discount > property self.discount (self.discount / 100) (25 / 100) "Discounted: {self.name}" Chapter 6 Python Core > print() input() super() install python Python Standard > installed with python BUT import keyword and from and as keyword optional Python Custom > Your libraries import keyword rules PIP > install with the pip command pypi.org Level 3 pandas, numpy, pypdf, etc. Lunch 1 E - 1:45 E Discussion Standard. High and Low Level Mods. Page 69 onlclabs.com click on python click on 12072023 files chapter6.py philipm@onlc.com 800.288.8221 Modules High Level and Low Level > architecture and design functional vs structural High Level Modules 1. UI/UX 2. workflow rules / operational 3. developers "get there faster" but control/cust/res mgmt 4. business logic Low Level Modules 1. component tech foundation 2. more skilled developer 3. resource allocation 4. granular control 5. device drives, db connections Standard "installed python" Library High Level 1. requests http requests 2. seaborn > matplotlib 3. flask Low Level 1. os 2. socket 3. multiprocessing 4. any sql conn mysqli sqllite3 jdbc odbc sql. datetime.year() whole function return def age(): var fullname = fn + ln var age = 21 return Philip Matusiak is 21 Contact.age calling the value Philip Matusiak is 21 2023 now() year() .year break 3:15 E - 3:30 E page 71 chapter6subprocess.py MAC Linux Windows high level ---------- os subprocess sys thread cpu ----------------------------- Array Data Frame pandas List [] Set {} Tuple () Dictionary {key:value} High Level collection defaultdict chainmap Low Level defaultdict class low level name > required *name > optional skip Optional name > optional **name > optional and it does not have to exist name visible *_name hidden __name meta Property my_dict = { null : null } python x = 7 y = 3 x,y = 7,3 pythonic MORE CODE Day 2 10 E defaultdict pythonic testing philipm@onlc.com chapter6dict.py my_dict = { } contacts = [] orders = () products = {} Pythonic > principles and concepts syntax of code function or action or event Allow than Deny forgiveness permission if (!condition): i dont have to do something else: run action App Factory PROVIDER file(txt/csv) I/O Service Modules as keyword > namespace Class try finally Object methods() and functions() as > alias property var with type string testing value if view if keywords break 11:40 E - 11:55 E regex discussion page 89 regex labs "philipm@onlc.com" re Module Standard import (555) 555-1212 ( (\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} Philip does it begin with a TitleCase r'^[A-Z][a-z*]?' ID: 0 Name: Philip Chapter 8 Testing UI/UX testing > flow and design front end Backend Testing OOP unit tester > unittest class based testing function tester > pytest function based testing lunch 1 E - 1:45 E page 97 unittest framework > Python Standard import pytest framework > pip install import "c:\newfolder\newfile.txt" > excape "c:/newfolder/newfile.txt" > linux @"c:\newfolder\newfile.txt" > verbose Suite Class add() multi() x = 7 print("Order ID:" + int(x) ) result(fname + " " + lname) sub() div() P