import numpy as np
class Generate(object):
def __init__(self):
self.group_images()
self.lock = figure # 這裏只是把變量self.lock指向了figure這個函數,沒有調用這個函數
self.z = with_bracket()
def group_images(self):
print('hello')
def figure():
print('figure')
def with_bracket():
print('with_bracket')
x = Generate()
x.lock() # 這裏才調用了figure函數
結果:
hello
with_bracket
figure