课程: Advanced Python: Build Hands-On Projects with Design Patterns (2023)
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Access control - Python教程
课程: Advanced Python: Build Hands-On Projects with Design Patterns (2023)
Solution: Access control
- [Instructor] Were you able to figure out the answer? In this challenge, I created an InterceptingValidator class for you. The self._validator attribute is where I store a reference to my validator that will validate an embedded input, t, I stored in the self._input attribute. I also have a method called set_validator to set the ._validator attribute to the validator I want, right here. The last method in the InterceptingValidator class is validate. This method invokes the validate method of my validator and returns the result of the validation. The result is either True or False. Let's now examine the NumberValidator class. I use this class to check if my input is a number or not. The validation process occurs in the validate method. I set the int_or_not variable to None initially. The goal is to set it to True if the input can be turned into an integer. Otherwise, the validate method should return False. I…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。