- The Python Apprentice
- Robert Smallshire Austin Bingham
- 121字
- 2021-07-02 22:17:01
Comments
We believe docstrings are the right place for most documentation in Python code. They explain how to consume the facilities your module provides rather than how it works. Ideally your code should be clean enough that ancillary explanation is not required. Nevertheless, it's sometimes necessary to explain why a particular approach has be chosen or a particular technique used, and we can do that using Python comments. Comments in Python begin with # and continue to the end of the line.
As a demonstration, let's document the fact that it might not be immediately obvious why we're using sys.argv[1] rather than sys.argv[0] in our call to main():
if __name__ == '__main__':
main(sys.argv[1]) # The 0th arg is the module filename.
推薦閱讀
- Java高并發(fā)核心編程(卷2):多線程、鎖、JMM、JUC、高并發(fā)設(shè)計模式
- Learning ArcGIS Pro 2
- Animate CC二維動畫設(shè)計與制作(微課版)
- Java:Data Science Made Easy
- Easy Web Development with WaveMaker
- Effective Python Penetration Testing
- Android開發(fā):從0到1 (清華開發(fā)者書庫)
- Kotlin編程實(shí)戰(zhàn):創(chuàng)建優(yōu)雅、富于表現(xiàn)力和高性能的JVM與Android應(yīng)用程序
- Learning Docker Networking
- Instant Zurb Foundation 4
- 超好玩的Scratch 3.5少兒編程
- JavaScript編程精解(原書第2版)
- Greenplum構(gòu)建實(shí)時數(shù)據(jù)倉庫實(shí)踐
- ASP.NET開發(fā)寶典
- Mastering Machine Learning with R