python的块注释_为什么在Python中没有块注释?

1586010002-jmsa.png

I''m still tyring to figure out what "Pythonic" means, and I have a

feeling the answer to my question may fall into that category. Are block

comments somehow unpythonic?

解决方案John Salerno wrote:

I''m still tyring to figure out what "Pythonic" means, and I have a

feeling the answer to my question may fall into that category. Are block

comments somehow unpythonic?

only in the sense that python don''t have them.

but they''re pretty pointless, if you have a modern editor.

(and if you don''t, you can quickly comment out regions by putting them

inside a triple-quoted string.)

Fredrik Lundh wrote:you can quickly comment out regions by putting them

inside a triple-quoted string.)

Except that triple-quotes don''t nest.

I do agree, however, with the idea that any decent editor should be

able to comment out a block of code faster than I can type this

sentence.

It''s clear that if you have a modern editor, block comments are

unnecessary because it is trivial to add a # to the start of each line

of a block, but that doesn''t really answer your question. It explains

why you might not always need block comments but doesn''t explain why

you shouldn''t use them (especially in a primitive editor).

The danger with block comments is that there is no way to tell that the

code you''re looking at has been commented out unless you can see the

start or end of the comment block. If you have a modern editor, it

probably changes the color of all commented out code to eliminate

confusion. But if you have a primitive editor it does not. Also, even

people who use modern editors sometimes browse source code using a

plain text viewer (less/more).

Eliminating block comments eliminates uncertainty. :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值