私はruby/C#の出身で、Pythonは初めてです。
私は次のコードを見ています:
def raiseFlag():
global flag
flag = 1
class TermStructureTest():
def testImpliedObs(self):
global flag
flag = None
h = RelinkableYieldTermStructureHandle()
settlement = self.termStructure.referenceDate()
new_settlement = self.calendar.advance(settlement,3,Years)
implied = ImpliedTermStructure(h,new_settlement)
obs = Observer(raiseFlag)
obs.registerWith(implied)
h.linkTo(self.termStructure)
if not flag:
self.fail("Observer was not notified of term structure change")
TermStructureTest()クラス内で「raiseFlag」を呼び出すことが機能するのはなぜですか?