ZhangZhihui's Blog  
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 78 下一页

2024年7月31日

摘要: 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 阅读(2) 评论(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 阅读(3) 评论(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 阅读(6) 评论(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 阅读(3) 评论(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 阅读(4) 评论(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 阅读(4) 评论(0) 推荐(0) 编辑

2024年7月30日

摘要: The order in which Python searches for attributes in base classes is called method resolution order(MRO). It gives a linearized path for an inheritanc 阅读全文
posted @ 2024-07-30 22:07 ZhangZhihuiAAA 阅读(13) 评论(0) 推荐(0) 编辑
 
摘要: The magic methods __str__ and __repr__ are used for converting an instance object into a string. The method __str__ is invoked when an instance object 阅读全文
posted @ 2024-07-30 20:42 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: Creating Managed Attributes using properties Properties can be used to create data attributes with special functionality. If you want some extra funct 阅读全文
posted @ 2024-07-30 18:55 ZhangZhihuiAAA 阅读(3) 评论(0) 推荐(0) 编辑
 
摘要: Sometimes we have to write methods that are related to the class but do not need any access to instance or class data for performing their work. These 阅读全文
posted @ 2024-07-30 18:29 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 78 下一页