" Greg Ewing"写道:"Greg Ewing" wrote:更一般地说,我认为语句和表达式之间没有抽象的区别。一切都是表达式,可以评估一个值。 More generally, I think there is no abstract distinction between statements and expressions. Everything is an expression, can be evaluated to a value. 这在功能语言中是正确的,但Python不是一种功能语言。在命令式编程中,通常你只是为了副作用而做某事,并且返回没有明显的价值。在我看来,强迫一切只为了概念纯度而返回一个值是一种人为的。 That''s true in a functional language, but Python is not a functional language. In imperative programming, often you just do something for its side effect, and there''s no obvious value to return. Forcing everything to return a value just for the sake of conceptual purity is an artificiality, in my view. 嗯,我想是什么造成了人为的主观的话,因为IMO表达式和陈述之间的区别是一个更大的人工性。 Python已经使用默认值(None)从可调用函数返回 ,那么什么使语句特殊?当然不是 的副作用,因为设置属性的两种等效方式显示: ax = val#statement setattr(a, ''x'',val)#表达 乔治Well, I guess what makes an artificiality is subjective then, becauseIMO the distinction between expressions and statements is a biggerartificiality. Python already uses a default value (None) to returnfrom a callable, so what makes statements special ? Certainly not theside effects, as the two equivalent ways to set an attribute show:a.x = val # statementsetattr(a,''x'',val) # expressionGeorge 这篇关于抽象和具体的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 09:03