[Tutor] Docstring

Alan Gauld alan.gauld at btinternet.com
Mon Jun 8 17:57:53 CEST 2015


On 08/06/15 10:34, Sunil Tech wrote:

> what is the standard way of using docstrings?

As Steven said there are several "standards".

Yet another option is to use the format required
by doctest. For your example:

def test(x):
       """
       A dummy method
       >>> test(5)
       True
       >>> test(-5)
       False
       """

Or whatever test cases make sense.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list