Section 2.3. Comments


2.3. Comments

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.



Core Python Programming
Core Python Programming (2nd Edition)
ISBN: 0132269937
EAN: 2147483647
Year: 2004
Pages: 334
Authors: Wesley J Chun

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net