作为一种语言,是Python限制由于没有结束语句? [英] As a language, is Python limited due to no end statement?

查看:256
本文介绍了作为一种语言,是Python限制由于没有结束语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Python使用制表符间距来表示范围(因此,没有 end 的} 符号)



注意:我不是在谈论关于编码风格的个人偏好,我在说关于实际语言限制作为没有 end 语句的直接结果?



直接从Guido发布的帖子,缺少多行因为Python没有终止结束 / } 符号?


$ b b

如果是,还有什么其他Python限制,因为这种语言设计决定使用缩进?






更新:



请注意,这个问题不是关于Lambda和技术上的,甚至不是Python本身。它是关于编程语言设计...当编程语言设计为缩进(而不是结束语句)代表块范围时,编程语言有什么限制。

解决方案

没有缺少 end / } :结尾由 dedent到以前的深度。



示例:

  x = 123 
,而x> 10:
if x%21:
print(x)
print(y)
print(z)

begin对应于缩进级别增加(后,



end对应于缩进级别的减少(在各个 () s)。



如果省略 print(y) ,你有一个最重要的到最高级别,这对应有两个连续的结束。


Since Python uses tabs spacing to indicate scope (and as such, has no end of } symbols), does that limit the language in any way from having particular functionality?

Note: I'm not talking about personal preferences on coding-style, I'm talking about real language limitation as a direct result of not having an end statement?

For example, it appears by a post directly from Guido that the lack of multi-line lamba's due to Python not having a terminating end / } symbol?

If so, what other Python limations are there because of this language design decision to use indentation?


Update:

Please note this question is not about Lambda's and technically, not even Python per se. It's about programming language design ... and what limitations does a programming language have when it's designed to have indentation (as opposed to end statements) represent block scope.

解决方案

There is no lack of end/ }: an end is represented by a "dedent" to the previous depth. So there is no limitation in any way.

Example:

x = 123
while x > 10:
    if x % 21:
        print("x")
    print("y")
print("z")

A "begin" corresponds to increasing of indentation level (after while, after if).

An "end" corresponds to decreasing of indentation level (after the respective print()s).

If you omit the print("y"), you have a "dedentation" to the topmost level, which corresponds to having two successive "end"s.

这篇关于作为一种语言,是Python限制由于没有结束语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆