ZhangZhihui's Blog  
上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 102 下一页

2024年7月31日

摘要: When we talk about decorating classes, we can either decorate individual methods or we can create a decorator to decorate the whole class. class MyCla 阅读全文
posted @ 2024-07-31 15:28 ZhangZhihuiAAA 阅读(15) 评论(0) 推荐(0)
 
摘要: A decorator is a callable that takes a callable as input and returns a callable. This is the general definition of a decorator. The callable in this d 阅读全文
posted @ 2024-07-31 15:19 ZhangZhihuiAAA 阅读(11) 评论(0) 推荐(0)
 
摘要: The task of implementing iterators can be simplified by using generators. We have seen how to create custom iterators using the object-oriented way, i 阅读全文
posted @ 2024-07-31 11:20 ZhangZhihuiAAA 阅读(30) 评论(0) 推荐(0)
 
摘要: The itertools module contains special functions to create iterators for efficient looping. It has three broad categories of iterators - infinite itera 阅读全文
posted @ 2024-07-31 10:40 ZhangZhihuiAAA 阅读(11) 评论(0) 推荐(0)
 
摘要: If we want objects of this class to be used in iteration contexts, then they should support the iteration protocol. To make this class iterable, we ca 阅读全文
posted @ 2024-07-31 10:33 ZhangZhihuiAAA 阅读(8) 评论(0) 推荐(0)
 
摘要: In our first example, we will create iterable objects, which, when iterated over, will give out cubes of numbers, and these objects will support multi 阅读全文
posted @ 2024-07-31 10:29 ZhangZhihuiAAA 阅读(14) 评论(0) 推荐(0)
 
摘要: There are many built-in functions and methods that return iterables and iterators. Here are a few examples: range() returns an iterable dict.keys() re 阅读全文
posted @ 2024-07-31 09:43 ZhangZhihuiAAA 阅读(14) 评论(0) 推荐(0)
 
摘要: class Engine: def __init__(self,power): self.power = power def start(self): self.draw_current() self.spin() self.ignite() def draw_current(self): prin 阅读全文
posted @ 2024-07-31 09:34 ZhangZhihuiAAA 阅读(9) 评论(0) 推荐(0)
 
摘要: We have seen that if we have to define a group of classes that have similar features and show common behavior, we can define a base class and then inh 阅读全文
posted @ 2024-07-31 09:30 ZhangZhihuiAAA 阅读(12) 评论(0) 推荐(0)
 
摘要: The three main features of object-oriented programming are - encapsulation, inheritance and polymorphism. We have seen the first two, now let us see w 阅读全文
posted @ 2024-07-31 09:19 ZhangZhihuiAAA 阅读(20) 评论(0) 推荐(0)
上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 102 下一页