![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
英文笔记
文章平均质量分 86
阅读和学习英文官方文档,整理笔记
Bruce_Liuxiaowei
“对我而言, 武术的非凡之处在于它的简单。简单的方法也是正确的方法,同时武术也没有什么特别之处。越接近武术的真谛,招式表现上浪费越少。”
--Bruce Lee, Jeet Kune Do 创始人
展开
-
Python‘s Standard Library :Networking
Python的标准库为创建网络服务和远程访问服务提供了一些模块。例如:等。原创 2023-04-15 13:21:45 · 399 阅读 · 0 评论 -
Python Tricks-- Abstract Base Classes Keep Inheritance in Check
Abstract Base Classes(ABCs) ensure that derived classes implement particular methods from the base class. In this chapter you’ll learn about the benefits of abstract base classes and how to define them with Python’s built-in abc module.So what are Abstract原创 2022-06-03 15:57:14 · 95 阅读 · 1 评论 -
Cloning Objects for Fun and Profit
Cloning Objects for Fun and ProfitAassignment statements in Python do not create copies of objects, they only bind names to an object. For immutable objects, that usually doesn’t make a difference.But for working with mutable objects or collections of m原创 2022-05-30 22:20:58 · 122 阅读 · 0 评论 -
Classes & OOP--Defining Your Own Exception Classes
Classes & OOP–Defining Your Own Exception ClassesWhen I started using Python, I was hesitant to write custom exception classes in my code. But defining your own error types can be of great value. You’ll make potential error cases stand out clearly, a原创 2022-05-27 10:04:14 · 330 阅读 · 1 评论 -
Python Tricks: String Conversion(Every Class Needs a ___repr__)
Python Tricks: String Conversion(Every Class Needs a __repr__)When you define a custom class in Python and then try to print one of its instance to the console(or inspect in an interpreter session), you get a relatively unsatisfying result. The default “t原创 2022-05-24 19:19:48 · 380 阅读 · 0 评论 -
Python Tricks--- Object Comparisons:“is” vs “==”
Python Tricks— Object Comparisons:“is” vs “==”When I was a kid, our neighbors had two twin cats. They looked seemingly identical–the same charcoal fur and the same piercing green eyes. Some personality quirks aside, you couldn’t tell them apart just from原创 2022-05-23 17:02:51 · 115 阅读 · 0 评论 -
Python Tricks: Nothing to Return Here
Python Tricks: Nothing to Return HerePython adds an implicit return None statement to the end of any function. Therefore, if a function doesn’t specify a return value, it returns None by default.This means you can replace return None statements with bare原创 2022-05-21 07:19:17 · 135 阅读 · 0 评论 -
Python Tricks : Function Argument Unpacking
Python Tricks: Function Argument UnpackingA really cool but slightly arcane feature is the ability to “unpack” funciton arguments from sequences and dictionaries with the * and ** operators.Let’s define a simple funciton to work with as an example:In [3原创 2022-05-20 17:06:47 · 231 阅读 · 0 评论 -
Python Tricks : Fun With args and kwargs
Python Tricks: Fun With *args and **kwargsI once pair-programmed with a smart Pythonista who would exclaim “argh!” and “kwargh!” every time he typed out a function definition with optional or keyword parameters. We got along great otherwise, I guess that原创 2022-05-19 10:56:31 · 115 阅读 · 0 评论 -
Python Tricks : How to Write Debuggable Decorators
Python Tricks: How to Write “Debuggable” DecoratorsWhen you use a decorator, really what you’re doing is replacing one funciton with another. One downside of this process is that it “hides” some of the metadata attached to the original(undecorated) functi原创 2022-05-17 20:45:38 · 134 阅读 · 0 评论 -
Python Tricks :The Power Of Decorators
Python Tricks: The Power Of DecoratorsAt their core, Python’s decorators allow you to extend and modify the behavior of a callable(functions , methods, and classes) without permanently modifying the callable itself.Any sufficiently generic functionality原创 2022-05-16 14:48:35 · 420 阅读 · 0 评论 -
Python Tricks: A Shocking Truth About String Formatting
Python Tricks: A Shocking Truth About String FormattingRemember the Zen of Python and how there should be “one obvious way to do something ?” You might scratch your head when you find out that there are four major ways to do string formatting in Python.原创 2022-05-10 21:06:25 · 283 阅读 · 0 评论 -
Python Tricks :Lambdas Are Single-Expression Functions
Python Tricks: Lambdas Are Single-Expression FunctionsThe lambda keyword in Python provides a shortcut for declaring small anonymous functions. Lambda functions behave just like regular functions declared with the def keyword. They can be used whenever f原创 2022-05-14 14:25:32 · 406 阅读 · 0 评论 -
Python‘s Assert Syntax
Python’s Assert SyntaxIt’s always a good idea to study up on how a language feature is actually implemented in Python before you start using it. So let’s take a quick look at the syntax for the assert statement, according to the Python docs:assert_stmt原创 2022-05-03 22:04:03 · 529 阅读 · 0 评论 -
Python Tricks : Complacent Comma Placement
Python Tricks: Complacent Comma PlacementHere’s a handy tip for when you’re adding and removing items from a list, dict, or set constant in Python:Just end all of your lines with a comma.Not sure what I’m talking about? Let me give you a quick example.原创 2022-05-05 19:11:17 · 248 阅读 · 0 评论 -
Python tricks Context Managers and the with Statement
Python tricks: Context Managers and the with StatementThe with statement in Python is regarded as an obscure feature by some. But when you peek behind the scenes, you’ll see that there’s no magic involved, and it’s actually a highly useful feature that c原创 2022-05-06 13:35:21 · 336 阅读 · 0 评论 -
“The Zen of Python” Easter Egg
Python Tricks: “The Zen of Python” Easter EggBut there’s really no way around Tim Peters’ Zen of python. I guess that everyone who like to learn Python language must have benefited from revisiting it over the years, and I think Tim’s words made every pro原创 2022-05-11 20:14:26 · 188 阅读 · 0 评论 -
Python tricksUnderscores, Dunders, and More
Python tricks:Underscores, Dunders, and MoreSingle and double underscores have a meaning in Python variable and method names. Some of that meaning is merely by convention and intended as a hint to the programmer–and someof it is enforced by the Python in原创 2022-05-07 20:15:38 · 454 阅读 · 0 评论 -
Python Tricks:Python‘s Functions Are First-Class
Python Tricks:Python’s Functions Are First-ClassPython’s functions are first-class objects. You can assign them to variables, store them in data structures, pass them as arguments to other functions, and even return them as values from other functions.Gr原创 2022-05-12 23:09:03 · 223 阅读 · 1 评论