def goodbye( name, adjective ):
print "goodbye %s %s"%( name, adjective )
def bye(info):
print "printed on exiting", info
import atexit
atexit.register( goodbye, adjective="cat", name="dog")
atexit.register( bye , info="cat")
atexit.register( bye , info="dog")
不过python的回调顺序是添加顺序的逆序!
这里的结果为:
printed on exiting dog
printed on exiting cat
goodbye dog cat
print "goodbye %s %s"%( name, adjective )
def bye(info):
print "printed on exiting", info
import atexit
atexit.register( goodbye, adjective="cat", name="dog")
atexit.register( bye , info="cat")
atexit.register( bye , info="dog")
不过python的回调顺序是添加顺序的逆序!
这里的结果为:
printed on exiting dog
printed on exiting cat
goodbye dog cat
No comments:
Post a Comment