请写更多惯用 Pythonic 代码

原文: PyCoder's Weekly - Issue #436

pycoder

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

Augmented arithmetic assignment happen whenever you do a bit of arithmetic while also assigning a value, such as a += 1. Learn how this assignment works under the hood and how the discovery of a bug in Python lead to the conclusion that most people never use the **= operator.

In this tutorial, you’ll learn about Python’s data structures. You’ll look at several implementations of abstract data types and learn which implementations are best for your specific use cases.

(是也乎:

Guide

Python 内置数据结构真的是常讲常新哪...

)

Learn how to use dependency injection to write loosely-coupled yet highly-cohesive code.

(是也乎:

一切为了 松耦合+高内聚

)

Learn some of the idioms and conventions that can make your Python code more readable, effective, concise and reliable.

The Real Python Office Hours is a weekly hangout where members of Real Python get the chance to interact with each other as well as Real Python authors and video course instructors. Join us live on Wednesday mornings!

(是也乎:

Office

在线开放日, 大家可以直接和 真蟒 成员交流.

)

探讨/吐糟

Discussions

(是也乎:

比如:

from datetime import date
user = 'eric_idle'
member_since = date(1975, 7, 31)
f'{user=} {member_since=}'

输出:

"user='eric_idle' member_since=datetime.date(1975, 7, 31)"

海象语法糖之后, Python 将包含越来越多不会生龋齿的糖...

)

That’s a.... creative one-liner!

(是也乎:

代码:oneliners/snake.py at master · tjf801/oneliners · GitHub

(lambda pygame=import('pygame'),random=import('random'),WIDTH=800 ... )())())())()))()

真的是只有一行,不过长达 3.18K;

可以说, 将 Python 多范式特性玩到位了, 将 Python 写成 LISP 没毛病.

)

文章/教程/嗯哼

Articles, Tutorials and Talks

Have you wondered, how should I package my Python code? You’ve written the application, but now you need to distribute it to the machines it’s intended to run on. It depends on what the code is, the libraries it depends on, and with whom do you want to share it. This week on the show we have Itamar Turner-Trauring, creator of the website pythonspeed.com. We discuss his article “Options for Packaging Your Python Code: Wheels, Conda, Docker, and More,” covering the how of sharing your code.

(是也乎:

Episode

)

The as keyword from SQL is a wonderful one. You can create a complex function on a database column, and then give it an explicit name. This name can be used later in the pipeline as a reference. pandas, even though superior to SQL in most ways, really lacked this until fairly recently. Not anymore…

(是也乎:

凉凉有很多原由, 在 Python 世界, 最大的原因就是不够 Pythonic.

)

Optimization algorithms are the backbone of machine learning and deep learning. Get your hands dirty by solving two classic numerical problems. You’ll learn how to translate an abstract problem into Python code, as well as how to implement a couple of optimization algorithms.

In this course, you’ll learn how to handle spreadsheets in Python using the openpyxl package. You’ll learn how to manipulate Excel spreadsheets, extract information from spreadsheets, create simple or more complex spreadsheets, including adding styles, charts, and so on.

(是也乎:

openpyxl

csv 毕竟不太香...

)

If you have a large CSV file, you might use gzip to compress the file when you are storing it. But here’s a thought: why not compress each row of the file and concatenate them into a database of smaller files? Learn how and why you might want to do this.

(是也乎:

gzip 毕竟是开源的, 实在被 Python 们玩儿透了..

)

In this course, you’ll learn everything you need to know about HTTP redirects in Django. All the way from the low-level details of the HTTP protocol to the high-level way of dealing with them in Django.

(是也乎:

Redirects

)

Magic, or “dunder,” methods are an important part of creating custom classes in Python. Learn about some commonly used magic methods by exploring hem in pairs that are frequently used together.

Learn how to use open air traffic data to plot aircraft positions on a map and build an interactive web application using the Bokeh plotting framework.

(是也乎:

Bokeh 是个好框架, 只是后来取消直接图片输出, 是个囧操作...

)

好物/妙品/...

Interesting Projects, Tools and Libraries, Projects & Code

(是也乎:

不是创作平台, 是后期处理框架.

)

(是也乎:

反正大家就是对 crontab 看不上眼, 太难以调试了...

不过, 无论什么其它方案, 都难以拼过 crontab 的稳定哪

)

📆🐍 活动/大会

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

(是也乎:

zoom 提供的网络活动服务.

Webinar

)

(是也乎:

真的猛士是无视疫情的...

)

DAMA

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

101camp12py 正在报名

报名

课程规划:

    报名截止 2020.09.21
    正式开课 2020.09.27
    课程结束 2020.11.08

详情 => 蟒营®编程思维提高班 Python版/ 第12期

PS:


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

投稿/反馈邮箱:

askdama@googlegroups.com

(邮件列表地址, 当成正常邮件发送邮件就好, 不用注册, 不用翻越...)


ZoomQuiet/大妈

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

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

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

NN 4124

RPP


Comments



蟒营®编程思维提高班 Python版/第13期 正在报名

精品小班/ 永久答疑

扫描报名: 101camp13py

蟒营®式 原创课程

伴你重享学习乐趣

官网: py.101.camp

Reactivate Joy by Self-teching with You


任何问题可先进入知识星球(免费)咨询:
FAQ

关注公众号, 持续获得相关各种咨询:
mainium


追问

任何问题, 随时邮件提问可也:
askdama@googlegroups.com