Multi-line docstrings
Lawrence D'Oliveiro
ldo at geek-central.gen.new_zealand
Sat Dec 23 06:21:13 EST 2006
More information about the Python-list mailing list
Sat Dec 23 06:21:13 EST 2006
- Previous message (by thread): Multi-line docstrings
- Next message (by thread): Multi-line docstrings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The Python docs recommend the use of triple-quoted string literals for
docstrings, e.g.
def Meet(Alice, Bob) :
"""arranges a meeting between Alice and Bob.
Returns a reference to the meeting booking object."""
...
#end Meet
However, these tend to get messed up by indentation whitespace, which gets
spuriously included as part of the string.
Another possibility is to use implicit concatenation of string literals,
e.g.
def Meet(Alice, Bob) :
"arranges a meeting between Alice and Bob." \
" Returns a reference to the meeting booking object."
...
#end Meet
This includes no spurious whitespace, or even any newlines; if you want
these, you must put them explicitly in the string:
def Meet(Alice, Bob) :
"arranges a meeting between Alice and Bob.\n" \
"Returns a reference to the meeting booking object."
...
#end Meet
- Previous message (by thread): Multi-line docstrings
- Next message (by thread): Multi-line docstrings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list