Home > Articles > Open Source > Python

  • Print
  • + Share This
This chapter is from the book


As with most scripting and Unix-shell languages, the hash or pound ( # ) sign signals that a comment begins from the # and continues until the end of the line.

>>> # one comment
... print 'Hello World!' # another comment
Hello World!

There are special comments called documentation strings, or “doc strings” for short. You can add a “comment” at the beginning of a module, class, or function string that serves as a doc string, a feature familiar to Java programmers:

def foo():
    "This is a doc string."
    return True

Unlike regular comments, however, doc strings can be accessed at runtime and be used to automatically generate documentation.

  • + Share This
  • 🔖 Save To Your Account