首页 > 后端开发 > Python教程 > Pycharm里面的TODO功能有什么作用?

Pycharm里面的TODO功能有什么作用?

WBOY
发布: 2016-06-06 16:23:23
原创
3883 人浏览过

回复内容:

When working on a project, it's often needed to create a list of tasks for yourself or your team mates. While usually these tasks are described in an issue tracker like YouTrack, some tasks are either too small or too code-specific to describe in an issue tracker. In such a case, adding TODO comments in source code makes sense.
具体来说,当你在写代码时,突然意识到你之前的代码有一个潜在的小bug,但不重要,一般人通常的做法是:
  • 立刻去修复bug,然后当你返回你现在的工作时,你的思路就被打断了
  • 把bug记在脑子里,继续写你的代码,很快这个bug就被你忘了
  • 在bug的地方打一个注释,继续写代码,很快这个bug又被你忘了,很久以后,当你翻之前的代码时你才发现这里有个注释
  • ……
明智的做法是:
在bug旁边写一个“#todo: computer will explode while running the program for 24+ hours”,然后继续写代码。
为了防止你今后忘掉这个bug,pycharm会在3个地方提示你:
Pycharm里面的TODO功能有什么作用?
另外,在多人协作的项目中,todo还可以用来区分“谁要去修复这个bug”。PyCharm官方文档介绍如下:
create several filters, which you will use to show the TODO items, say, for each of the developers, and not for your good self. For this purpose, in the Filters section, click , and specify the filter names, for example, For John, For Bob, and not for me. Associate these filters with the patterns:
Pycharm里面的TODO功能有什么作用?
Now, in the source code, create TODO items: in the line of code, where you want to add a note, press Ctrl+Slash, or Ctrl+Shift+Slash, and type TODO that matches one of the patterns, followed by some meaningful description:
Pycharm里面的TODO功能有什么作用?
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板