關於 selfPython Class 裡的 self 會回傳物件本身 (根據物件位址並自動 derefference 為物件)。
self 有點類似 linux kernel 的 macro 中的 container_of,或 linux kernel 的 macro 中 list_entry// list_entry 就是 container_of,
// 放在 list.h 中,作為 list API 為了命名統一而重新命名
// 用來獲取「封裝 `struct list_head` 的
// container (也是一個 `struct`) 的『address』」
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
所以用 linux kernel 的風格來理解的話,==self 就是 The object of object_entry==。<br>由以下程式碼印出 self 訊息,可見 self 就是存於位址 (0x7ffbf95e94c0) 的 calss A 的物件。我所說的 object_entry 就是那段記憶體位址 (0x7ffbf95e94c0)。class A():
def __init__(self):
print(self)