Section 6: Module, Package และโครงสร้างโปรเจกต์
- import, Package และโครงสร้างโฟลเดอร์แบบ src Layout
- if __name__ == "__main__" และ Entry Point
- Explicit Lazy Imports ใน Python 3.15 เพื่อลดเวลาเริ่มต้นโปรแกรม
- Lab: แยกโค้ด StockSense เป็นโมดูลตามหน้าที่
Section 7: Type Hints และการตรวจชนิดข้อมูล
- Type Hints สำหรับตัวแปร ฟังก์ชัน และ Collection
- Union, Optional, Literal, TypedDict และ Protocol
- ตรวจสอบด้วย mypy หรือ Pyright และอ่านผลการตรวจ
- Lab: ใส่ Type Hints ให้โค้ดเดิมและแก้จุดที่ Type Checker แจ้ง
Section 8: Object-Oriented Programming แบบ Python
- Class, __init__, Instance และ Class Attribute และ Method
- Inheritance, Composition และ Dunder Methods (__repr__, __eq__)
- @property, @classmethod และ @staticmethod
- ความต่างจาก OOP ใน Java และ C# ที่ผู้เรียนควรรู้
Section 9: dataclasses และ Enum
- @dataclass พร้อม frozen, field และ __post_init__ สำหรับตรวจสอบข้อมูล
- Enum สำหรับค่าที่จำกัด เช่น หมวดหมู่และประเภทการเคลื่อนไหวของสต็อก
- เปรียบเทียบ dataclasses กับ NamedTuple และ dict
- Lab: ออกแบบโมเดล Product และ StockMovement
Section 10: Workshop: ไฟล์ ข้อมูล และ Error Handling
- pathlib การอ่านเขียนไฟล์ และ UTF-8 ที่เป็นค่าเริ่มต้นใน Python 3.15
- อ่านเขียน CSV และ JSON
- try, except, else, finally, Custom Exception และ Exception Chaining
- Context Manager ด้วย with และการสร้างเองด้วย contextlib
- Workshop: นำเข้าสินค้าจาก CSV ส่งออกรายงาน JSON และจัดการข้อมูลผิดรูปแบบ