cssmagic / Learn-AI-Assisted-Python-Programming

📖 《AI 辅助编程》这本书的大本营。
136 stars 13 forks source link

[译] [400] 第四章 理解 Python 代码(上) #25

Open cssmagic opened 6 months ago

cssmagic commented 6 months ago

4 Reading Python Code: Part 1

第四章 理解 Python 代码(上)

This chapter covers

本章内容概要

In Chapter 3, we used Copilot to write several functions for us. What are they good for? Maybe our money_made function could be part of a stock trading system. Maybe our is_strong_password function could be used as part of a social network website. Maybe our best_word function could be used as part of some Scrabble AI. Overall, we’ve written some useful functions that could be part of larger programs. And we did this without writing much code ourselves or, indeed, understanding what the code even does.

在第三章,我们借助 Copilot 编写了几个有用的函数。这些函数能用在哪里呢?例如,我们的 money_made 函数可能成为股票交易系统的一部分;is_strong_password 函数可以用于社交网站的密码强度检测;best_word 函数则可能应用于 Scrabble 游戏的 AI 中。归根结底,我们编写了若干可以成为大型程序组成部分的实用函数,而这一切几乎不需要我们自己动手编写代码,或者完全理解这些代码的具体作用。

However, we believe that you need to understand at a high-level what code does and that this will require some time to learn, hence we’ve split this across two chapters. In this chapter, we’ll explain why reading code is important and introduce you to a Copilot labs feature that can help you understand the code. After that, we'll dive into the top ten programming features you’ll need to be able to recognize in order to read most basic code produced by Copilot. We’ll do the first five in this chapter and the remaining five in the next chapter. Don't worry: you've actually been informally introduced to all ten already—we're just going to deepen your understanding of each one.

然而,我们相信你需要从高层次理解代码的作用,这将需要一些时间来学习,因此我们将这部分内容分为两章。在本章中,我们将解释为什么阅读代码是重要的,并介绍一个 Copilot 实验室的特性,该特性能帮助你理解代码。之后,我们会深入讨论十个编程特性,这些特性对于阅读 Copilot 产出的大多数基础代码来说是必需认识的。我们会在本章介绍前五个特性,在下一章介绍剩余的五个。不用担心:你其实已经非正式地了解了这十个特性——我们只是要深化你对它们每一个的理解。

cssmagic commented 1 month ago

👉 想要更多译稿预览,请前往 总目录 中按章节阅读。