嫑再将你 Python 模块命名为 utils

原文: PyCoder's Weekly - Issue #416

PyCoder

  • 200415 Zoom.Quiet(大妈) 用时 42 分钟 完成快译
  • 200415 Zoom.Quiet(大妈) 用时 37 分钟 完成格式转抄.

With so much of the world stuck at home thanks to the COVID-19 pandemic, more and more workplaces are using video conferencing solutions—such as Zoom—to bring work to your living room. Or kitchen. Or bedroom. Or bathroom. OK… hopefully not that last one! Why not spice up your video conferencing with some awesome, homemade virtual backgrounds built with Python and OpenCV?

(是也乎:

用一个简单例子来描述, 开源世界机械视觉最常见的应用...

OpenCV

)

Learn about inheritance and composition in Python. You’ll improve your object-oriented programming (OOP) skills by understanding how to use inheritance and composition and how to leverage them in their design.

(是也乎:

OOP

很多 OOP 概念都是在特殊场景中才感觉舒服的... 但是,我们学习使用却反过来, 先尝试理解各种模型, 再去撞场景...

)

“Do not use utils as a name for your Python module neither put it into a class name. Try to be more specific about the role of code – e.g. create a place for validators, services or factories. If the role criterion doesn’t help and you really dealing with utils, try grouping code by its theme.”

(是也乎:

utils 已经变成垃圾箱了... 最好给出真正有意义的模块名

)

In a recent article, Itamar Turner-Trauring discussed how to read large datasets with Pandas using a chunking technique to reduce memory overhead. Chunking has another advantage: it enables parallelism, which can dramatically speed up processing time. Learn why and how to enable parallelism for your Pandas processing code using the Dask library.

“Seven common ways a data science role may not meet your expectations through tens of data scientist interviews and anecdotes from popular media.” Also see the related discussion on Hacker News

In this step-by-step tutorial, you’ll learn how to use fixtures to simplify your testing in pytest. If you use Django, pytest fixtures can help you write tests that are painless to update and maintain even as you make changes to your models.

讨论

Discussions

If you pass two generators to zip(), then the iterator returned by zip() stops whenever the shorter of the two generators runs out of values. If the generator passed to zip() in the first position is larger than the second, then there is an “extra” value consumed from the larger generator. Why does this happen, and is it possible to retrieve the extra value consumed by zip()?

Comparing a single value against a number of conditions can result in long if/elif blocks. Is there a short and clean way to handle these comparisons?

(是也乎:

因为终于有资金注入了?

)

文章,教程和嗯哼

Articles, Tutorials and Talks

NumPy is fast, but it doesn’t play well with GPUs. For that, you can use CuPy, a drop-in NumPy replacement for GPUs developed by Nvidia. Now, what if I told you to crunch those numbers in Clojure on a GPU instead? Surely a language that compiles to Java couldn’t beat C++ optimized for CUDA, could it? Dragan Djuric, author of Numerical Linear Algebra for Programmers compares CuPy and Clojure on a GPU, with some surprising results.

(是也乎:

见到 Clojure 很惊讶嘛?

)

Testing an application’s interaction with a third-party service can be difficult and frustrating. But sometimes a lot of business logic is wrapped up in those interactions, so testing them is important for building trust in the application. This article compares and contrasts three options for testing Amazon S3 integration using the pytest framework.

(是也乎:

弄S3 三法宝: moto/boto3/Localstack

其实, 还是官方给的 SDK 放心哪

)

Domain-specific languages (DSL) bring the power of high-level programming to domain experts (read: non-programmers). In this article, Federico Tomassetti walks you through the process of creating a DSL with the textX Python library. As a bonus, you’ll also learn how to create syntax highlighting extension for VS Code that understands your language.

(是也乎:

VSCode 也纳入了自己的生态圈, 非常聪明了.

)

“Decision trees are a popular supervised learning method for a variety of reasons. Benefits of decision trees include that they can be used for both regression and classification, they don’t require feature scaling, and they are relatively easy to interpret as you can visualize decision trees. This is not only a powerful way to understand your model, but also to communicate how your model works. Consequently, it would help to know how to make a visualization based on your model.”

John Horton Conway was one of the most influential mathematicians of the 20th and 21st centuries. His “Game of Life” spawned countless implementation—nearly becoming a rite of passage for programmers in any language. Sadly, the world lost this brilliant mind on April 11 due to complications from COVID-19. Renowned mathematician Terry Tao has also published a memoir in honor of John Conway on his blog.

(是也乎:

大家都知道了, 生命游戏创始人, 可人家真的不是电子游戏... )

After reading an article about comparing a stock portfolio to the S&P 500, Matt Grierson wanted to go deeper and model a portfolio’s performance by analyzing buys and sells from a CSV file and calculating the rate of return relative to an index across any specified timeframe. This turned out to be more involved than Matt first thought it would be! Fortunately, Matt decided to share his experience—and his solution.

George Ho proposed a change to PyMC4’s model specification API that he thought would help make the user experience more straightforward. Although those changes weren’t ultimately accepted by his fellow PyMC4 core developers, the process led him into some interesting explorations into Python’s abstract syntax tree.

An interview with Martin Breuss on getting started with Django, and how to learn Python through errors, and how errors really are your friends. Martin talks about his work with Coding Nomads, and teaching Python around the world. He also provides some tips on debugging and writing good questions.

(是也乎:

podcast

podcast 在国外一直是个稳定的交流渠道, 在中国好象因为电台专营, 长期没了这个习惯.

)

In this step-by-step tutorial, you’ll learn three techniques for combining data in Pandas: merge, join, and concat. Combining Series and DataFrame objects in Pandas is a powerful way to gain new insights into your data.

(是也乎:

Pandas

两个函式, 就一大篇文章, 真蟒是真用心哪

)

(是也乎:

一个友好的中间码展示工具 )

好物

Interesting Projects, Tools and Libraries, Projects & Code

(是也乎:

创造语言的语言, 元语言, 而且提供 IDE 可视化分析...

textX

)

(是也乎:

等等, Yahoo 还活着?

)

(是也乎:

chord

生成这种和弦图, 而且能互动.

)

(( ̄▽ ̄):

叕一个 Nim 的扩展了, 无论有什么新语言诞生, Python 总是能第一时间拓展过去...

)

(是也乎:

Contextualise

看起来功能很强大... 但是,还没到可以投入使用的阶段?

)

📆🐍 活动/大会

Events, MeetUp 真的是全球线下活动组织中心

DAMA

❤️ Happy Pythonic ;-(大妈私人无责任播报)

101camp7py 马上(4.21)截止报名(能开发票 ;-)

参考:

PS:


NN 3984

好文笔,感叹号年度配额: 1/3

投稿/反馈邮箱:

askdama@googlegroups.com

ZoomQuiet/大妈

就是四处 是也乎,( ̄▽ ̄) 的那个大妈:

私自嗯哼: ZoomQuiet (订阅号: ZoomQuiet42)
公开课程: 蟒营 (订阅号: Mainium)
历史吐糟: Chaos42 (订阅号 PythoniCamp)

as 核心组织者:
    PyChina (订阅号: PyChinaOrg)
    本地社区: 
        GDG珠海 (订阅号: GDG-ZhuHai)
        TFUG珠海 (订阅号: ZH_TFUG)


Comments


大妈的多重宇宙 - YouTube

全新自媒体系列...科学幻想,读书,说故事...
点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

订阅 substack 体验古早写作:
Zoom.Quiet’s Chaos42 | Substack


关注公众号, 持续获得相关各种嗯哼:
zoomquiet


蟒营®编程思维提高班Python版

**2021.01.11** 因大妈再次创业暂停定期开设, 转换为预约触发:
  • + 任何问题, 随时邮件提问可也:
    askdama@googlegroups.com
-->