Kingname | 谢乾坤

One trick a day: Make your regular expressions a hundred times more readable

Original link: https://www.kingname.info/2022/06/20/readable-re/ Regular expressions are powerful, but they are written like an emoji. When I look at the expression I wrote in a month, I don’t even remember what it means. For example the following: 1 pattern = r”((?:\(\s*)?[AZ]*H\d+[az]*(?:\s*\+\s*[AZ]*H\d+[az]*)* (?:\s*[\):+])?)(.*?)(?=(?:\(\s*)?[AZ]*H\d+[az]*(?:\s* \+\s*[AZ]*H\d+[az]*)*(?:\s*[\):+])?(?![^\w\s])|$)” Is there any way to improve the readability of regular expressions? We know […]

One trick a day: Make your regular expressions a hundred times more readable Read More »

“From thesis to code, the engineering practice of academic research” live screen recording

Original link: https://www.kingname.info/2022/05/29/gne-origin/ PyCon China Python Meetup 2021 was originally planned to be held offline in 2021. Due to the force majeure of the epidemic, it was postponed to today’s online event. The topic I share today is “From paper to code, the engineering practice of academic research”. This paper introduces the origin of Gne-the

“From thesis to code, the engineering practice of academic research” live screen recording Read More »

One skill a day: Any and TypeVar, make the IDE’s auto-completion easier to use

Original link: https://www.kingname.info/2022/05/29/any-vs-typevar/ I believe that many students will use type annotations to improve the readability of the code when writing Python, and also help the IDE to achieve automatic completion. Suppose we now get an object, this object may be a list or a generator, I write a function to get its first element.

One skill a day: Any and TypeVar, make the IDE’s auto-completion easier to use Read More »

One skill a day: How to find discounted products from a large amount of product data?

Original link: https://www.kingname.info/2022/05/22/find-discount/ I believe that many students who are crawlers will crawl the e-commerce website once a day, and then monitor whether the price of the product is reduced. If you only monitor one product, it is very easy to judge whether the price is reduced, but if you want to find all the

One skill a day: How to find discounted products from a large amount of product data? Read More »

One skill a day: the perfect combination of coroutines and multi-processes

We know that coroutines are essentially single-threaded and single-process, and achieve high concurrency by making full use of IO wait time. Code outside the IO wait time is still run serially. Therefore, if there are many coroutines, how much the serial code running time inside each coroutine exceeds the waiting time of IO requests, then

One skill a day: the perfect combination of coroutines and multi-processes Read More »