[python-chinese] 在程序中使用yield报错,SyntaxError: 'return' with argument inside generator (xlrdT3a.py, line 246)
黄毅
yi.codeplayer在gmail.com
星期四 八月 2 09:01:26 HKT 2007
用了 yield 就不能用 return
On 8/1/07, 张建轶 <farsoftwind at gmail.com> wrote:
>
> 由于源程序比较长,而且很复杂
> 我简化了一下,如下所示:
>
> #!/usr/bin/python
>
> def ff():
> for i in range(1,5):
> print i
> buffc = []
> bufbc = []
> for j in range(1,4):
> print j
> buffc.append(u'1')
> bufbc.append(u'2')
> print buffc
> yield buffc
>
> for ss in ff():
> print ss
>
> 但这个简化程序正确编译通过,但源程序编译时报错,错误信息如下:
> SyntaxError: 'return' with argument inside generator ( xlrdT3a.py, line
> 246)
> 报错的246行的程序只是一句:
> yield bufxf
>
> 请问是怎么回事呢?如何修正?请教
>
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
--
http://codeplayer.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070802/b1f2789e/attachment.htm
关于邮件列表 python-chinese 的更多信息