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

2024年7月31日

摘要: >>> list(map(lambda x, y: x * y, [1,2,3,4], [5,6,7,8])) [5, 12, 21, 32] Here we have called the map function and sent a lambda expression as first arg 阅读全文
posted @ 2024-07-31 20:13 ZhangZhihuiAAA 阅读(6) 评论(0) 推荐(0) 编辑
 
摘要: Functional programming is a programming paradigm in which most of the work in a program is done using pure functions. A pure function is a function wi 阅读全文
posted @ 2024-07-31 17:23 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: We can place lambda function inside list and dictionary literals. This way we can use lambda expressions to create jump tables. >>> L = [lambda s: s.s 阅读全文
posted @ 2024-07-31 17:11 ZhangZhihuiAAA 阅读(2) 评论(0) 推荐(0) 编辑
 
摘要: A closure is a nested function that can access free variables from an enclosing function even after it has finished its execution. We know that, like 阅读全文
posted @ 2024-07-31 17:08 ZhangZhihuiAAA 阅读(2) 评论(0) 推荐(0) 编辑
 
摘要: We have used functions to decorate functions and to decorate classes. Now, we will see how to define a class as a decorator. At the start of this chap 阅读全文
posted @ 2024-07-31 16:24 ZhangZhihuiAAA 阅读(7) 评论(0) 推荐(0) 编辑
 
摘要: 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 阅读(5) 评论(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 阅读(4) 评论(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 阅读(13) 评论(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 阅读(3) 评论(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 阅读(2) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 78 下一页