我有点惊讶于以下行为:
def main(): print "%s" % foo if __name__ == "__main__": foo = "bar" main()
即模块函数可以访问封闭变量__main__.它的解释是什么?
__main__
python scope
python ×1
scope ×1