Tutorial by Examples

Comments are used to explain code when the basic code itself isn't clear. Python ignores comments, and so will not execute code in there, or raise syntax errors for plain english sentences. Single-line comments begin with the hash character (#) and are terminated by the end of line. Single lin...
Docstrings are - unlike regular comments - stored as an attribute of the function they document, meaning that you can access them programmatically. An example function def func(): """This is a function that does nothing at all""" return The docstring can ...
A docstring is a multi-line comment used to document modules, classes, functions and methods. It has to be the first statement of the component it describes. def hello(name): """Greet someone. Print a greeting ("Hello") for the person with the given name. &...

Page 1 of 1