首页 | 博客群 | 公社 | 专栏 | 论坛 | 图片 | 资讯 | 注册 | 帮助 | 博客联播 | 随机访问
●pyharu(libharu,PDF输出库)接口2.0.8发布- -| 回首页 | 2008年索引 | - -●关注两会

●独裁的GvR

                                      

有朋友提到如下两个程序的表现不一,于是我提交了一个bug(http://bugs.python.org/issue1888)。很快得到了GvR的答复,很显然,他的答复只是从一个python开发者的角度进行的;完全忽略python语法的一致性、考验大家对英语的理解(下面的yield我可以理解啊)。不过,也只好记着小心使用了,谁叫咱不会开发自己的语言呢。

#a.py
def run():
    if 1==2:                # note, it always False
        global a
    a=1

run()
a

#b.py
def run():
      a=1

run()
a

GvR的答复

This isn't going to change. 'global' is one of those rare pieces of
syntax that are not executed by the interpreter but detected by the parser.

Note that there are other things like this, e.g. the presence of 'yield'
in a function makes it a generator.

【作者: 冰冻牡蛎】【访问统计:】【2008年01月22日 星期二 17:19】【注册】【打印

搜索

Google

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=6610343

回复

验证码:   
评论内容: