Ebook Learning python (5th edition): Part 2

(BQ) Part 2 book "Learning python" has contents: Module coding basics, Modules - The big picture, module packages, advanced module topics, class coding basics, a more realistic example, class coding details, operator overloading, designing with classes, advanced class topics,.and other contents. | PART V Modules and Packages CHAPTER 22 Modules: The Big Picture This chapter begins our in-depth look at the Python module—the highest-level program organization unit, which packages program code and data for reuse, and provides selfcontained namespaces that minimize variable name clashes across your programs. In concrete terms, modules typically correspond to Python program files. Each file is a module, and modules import other modules to use the names they define. Modules might also correspond to extensions coded in external languages such as C, Java, or C#, and even to directories in package imports. Modules are processed with two statements and one important function: import Lets a client (importer) fetch a module as a whole from Allows clients to fetch particular names from a module (reload in ) Provides a way to reload a module’s code without stopping Python Chapter 3 introduced module fundamentals, and we’ve been using them ever since. The goal here is to expand on the core module concepts you’re already familiar with, and move on to explore more advanced module usage. This first chapter reviews module basics, and offers a general look at the role of modules in overall program structure. In the chapters that follow, we’ll dig into the coding details behind the theory. Along the way, we’ll flesh out module details omitted so far—you’ll learn about reloads, the _name_ and _all_ attributes, package imports, relative import syntax, namespace packages, and so on. Because modules and classes are really just glorified namespaces, we’ll formalize namespace concepts here as well. Why Use Modules? In short, modules provide an easy way to organize components into a system by serving as self-contained packages of variables known as namespaces. All the names defined at 669 the top level of a module file become attributes of the imported module object. As we saw in the last part

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
9    67    2    04-06-2024
10    4    1    04-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.