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

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate 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.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819