XPYM300307 InstructorPhilipM-1 https://onlclabs.com/python/03072024/ 10E - 1E 1E - 1:45E Lunch 1:45E - 4:45E Program Factory Docker / Kub / AWS Container Services / Tokenized Services PROVIDER IO txt csv dbconn json structural Service web services / micro services / api / injectors Class < blueprint define attributes and behaviors when created Object < functions(itself) methods(something else) mycalc() property (var name and data type) fname lname + join print(fname + ' ' + lname) assign value to a variable view print(f"{fname} {lname}) memory / processor / security stuck? 1. define? 2. defined value or action? 3. return? error? didn't define something Class attribute > property Class behavior > def method(p1, qs="string") mytest.py contacts.py property Contact.py TitleCase ClassName __name__ == "__main__" __init__ python jython java and python -> None break 12:05 E - 12:20E static instance and class methods page 57 Instance Method 1. Bound to a class thru the instance "new instance of a class" 2. self as the 1st parameter(self, fname, lname) 3. Perform operations specific to a class 4. Additional params have to be defined method(ex. fname, lname) Class Methods 1. Bound to a class BUT they do not use a "new instance of a class" 2. cls as the 1st parameter() 3. Additional params are defined as class attribute ex. ClassName(params1) class Contact(fname, lname) attrs of the class attributes indented in class class Contact: fname = None Static Methods 1. NOT bound to EITHER class or an instance 2. no 1st parameter self, cls 3. utility functions for the program "dont require access the the class" 4. decoration @staticmethod to define what type it is (one the line above0 Lunch 1:05 E - 1:50 E https://onlclabs.com/python/03072024/ static method page 57 getters and setters page 58 encapulate data > private variable OOP 1. dont encapsulate code in Python !{ ops; } 2. private variables different than hidden variable age = 21 public int variable age = '21' public string variable _age = 21 hidden int variable get_vipStatus = True getter boolean variable / attribute @property def vipStatus(True) property boolean method property(vipStatus) age = "21" string int(age) self._age hidden attr property(_age) class hidden property @property def func(): self._age vipStatus = "True" bool(vipStatus) bool( input("What is the status: " ) ) break 3:05 E - 3:20 E page 60-62 Parent / Child Inheritance Classes super() Interface with a Class Class with a Class !Class with an Interface Interface EXTENDS onto Class Inheritances Contact.fname,lname,add,c,s,zip Parent super ContactDetails.phone,email,department Child super() ContactPayroll.payrate,benefit1 class ContactDetails(Contact): def __init__(): super() class ContactPayroll(ContactDetails): class ContactPayroll(Contact): Python Core install python V.R.M 1<1991>,2,3 3.1 > 3.6 3.6 > 3.8 os sys 3.9 > 3.12 <3.13> 3 YR Feature 2 Yr Security Python Standard Library (C) built-in modules import keyword core Python Modules custom libs import or pip install import Modules Framework High Level Modules > programmer Low Level Modules > higher skillset OS and Python Interpreter > complex ----------- Virtualization Level Hardware Day 2 10 E labs for chapter 6 break 11:30 E - 11:45 E chapter 7 page 71 subprocess chapter7subprocess.py Change the chapter # to 6... woops We will fix after break fname, lname object > object fname + lname cast() types f'{fname} {lname}' view templates " First: {fname} last: {lname}" "o: {} d: {}", fname, lname @"First: {fname} last: {lname}" lunch 1:05 E - 1:50 E chapter 7 chapter7.py Pythonic # Python syntax # Pythonic syntax import re pythonic control > controlling the start and stop condition > test for continue or break exp or operation > action break 3:30 E - 3:45 E regular expressions chapter 8 pattern match [a-z] [A-Z] [0-9] [a,A,B,2] @ . ^ [0-9]{3} philipm@onlc.com philipm ^[] @ onlc . com $ debug syntax programmer / developer a + b = 10 7,3 error exception programmer / developer a + b = 10 7,3 ui/ux developer > ui/ux tester front end testing $10 cart back end testing pipeline works $10 credit card unit testers mocking data Asserting a + b ? # 21 7*3