Course Overview
This course begins with an expectation that students have had previous exposure to programming with Python, and understand the subjects outlined in Alta3 Python 101 - Essentials. The primary goals of this course include Object-Oriented Programming (OOP) structure and techniques, organizing code into user-defined modules and packages, error handling, and testing.
GitHub Actions or GitLab pipelines will be used to highlight the latest DevSecOps practices. Attendees will enable open source tools related to improving the usability and security of their Python scripts.
This course prepares students for the learning objectives found on Python Institute’s PCEP, PCAP and most of the PCPP1.
Class is a combination of live instructor demo and hands-on labs.
Prerequisites
- Python 201 - APIs and API Design with Python (AADP)
- Python 202 - Python for Network Automation (PNA)
- Git and GitHub (or Git and GitLab) (2 Days)
- Jenkins Automation Server Essentials (JASE)
Course Objectives
- Current Python 3.x Standard Library
- Object-Oriented Programming best practices
- Branching and Version controlling with git
- Git integration with popular SCM (GitHub or GitLab)
- Building User-Defined Modules and Packages
- DevSecOps Tools (GitHub Actions or GitLab CI/CD)
Outline: Python 102 - Advanced Python (ADVP)
1. Modules and Packages
- Modules and Packages defined
- "import" and use case for modules and packages
- "import" variants
- Exploring packages with "dir()"
- Defining "sys.path"
- Exploring host properties with "platform()", "machine()", "processor()", "system()", version()", "python_*()"
- Explaining underscores
- "__pycache__", "__name__", variables
- Purpose of "__init__.py" file
- Building a package
2. Exceptions
- Python defined exceptions
- "except" permutations
- Exception hierarchy
- Understanding "raise"
- How to use "assert"
- Writing your own exceptions
3. **I/O Operations**
- Understanding ASCII, UNICODE, UTF-8
- code points, and escape sequences
- How to use "in" and "not in"
- The functions "ord()" and "chr()"
- Controlling I/O flow
- text vs binary modes
- handles vs streams
- predefined streams
- bytearray for I/O buffering
- Why "open()" and "close()" (what are they actually doing?)
- The case for "with"
4. Object-Oriented Programming
- Classes
- Objects
- Objects and Properties
- Inheritance
- Superclassing
- Subclassing
- Instance variables
- Class variables
- Name mangling
- Understanding "self"
- Exploring classes with "hasattr()"
- "__module__", "__bases__", and "__name__"
- polymorphism
- Overriding "__str__()"
- Using the keyword "is"
- How to use "isinstance()"
- Defining constructors
5. Advanced Object-Oriented Programming
- Magic methods
- Comparison methods
- Numeric methods
- Object attribute access
- type conversion methods
- Duck typing
- Method Resolution Order (MRO)
- modeling real-life problems with "is a" and "has a" relations
- Understanding "*args" and "**kwargs"
- Decorators
- Stacking decorators
- Syntactic sugar
6. Advanced Techniques
- List comprehensions
- Lambda Functions
- Using "map()" and "filter()"
- Closures
- When to use shallow vs deep copies of objects
- Defining label, identity and value
7. Conventions and Testing
- PEP 8 Checking
- Documentation strings
- Naming conventions and naming styles
- Spacing in expressions and statements
- Recommendations for inline comments
- Documenting with README.md and requirements.txt
- Importance of version controlling your dependencies
- PyTest
- PyUnit framework
8. Intro to GUI Programming
- Using tkinter
- Creating buttons and frames
- Interacting with users
- Color modes RGB and HEX
- Widget properties and methods
- Checking input and handling errors
9. DevSecOps
- DevOps vs DevSecOps
- DevSecOps tools that quickly improve your Python code
- Fuzz testing Python APIs
- Checking your code for secrets with gitleaks
- (Optional) Automating tests with GitHub Actions
- (Optional) Automating test with GitLab CI/CD Pipelines