Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
119
4
物件導向的 Python
Python 是一個物件導向(object-orientedOO)程式語言。跟某些其他的
物件導向語言不同,Python 並不會強迫你只能使用物件導向典範:它也
以模組(modules)和函式(functions)支援程序式程式設計(procedural
programming),所以你能夠為你程式的各個部分選擇最佳的典範
paradigm)。物件導向典範能幫助你將狀態(資料)和行為(程式碼)包
成一組便利的功能性。當你想要使用涵蓋於本章中的某些 Python 物件導向
機制,例如
繼承
inheritance
特殊方法
special methods
,它也能派
上用場。如果你不需要物件導向程式設計的功能,那麼基於模組和函式的
程序式典範,可能會更為簡單且合適。透過 Python,你能夠混合搭配這些
典範。
今日的 Python 具有跟多年前不同的物件模型(object model)。本章只會描
述所謂的
新式模型
new-style
新物件模型
new object model
,它較
為簡單、更規則、更強大,而且也是我們建議你
永遠
都選用的那一個。每
當我們談及類別(classes)或實體(instances),我們指的都是新式的類別
或實體。然而,為了回溯相容性(backward compatibility), v2 中預設的
物件模型是
傳統物件模型
legacy object model
,也叫做
古典
classic
舊式
old-style
物件模型,而 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival

Publisher Resources

ISBN: 9789864766819