Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 16th, 2006, 03:05 PM
Colin J. Williams
Guest
 
Posts: n/a
Default Python Documentation Standards

Doc strings provide us with a great opportunity to illuminate our code.

In the example below, __init__ refers us to the class's documentation,
but the class doc doesn't help much.

Are there any guideline which cover such things?

PEP 8 <http://www.python.org/doc/peps/pep-0008/> has general advice.
PEP 257 <http://www.python.org/doc/peps/pep-0257/> provides more
detailed advice.

list provides a trivial example because it is very well documented
elsewhere but it does provide a template for others.

Colin W.

Colin W.[color=blue][color=green][color=darkred]
>>> list.__init__.__doc__[/color][/color][/color]
'x.__init__(...) initializes x; see x.__class__.__doc__ for signature'[color=blue][color=green][color=darkred]
>>> list.__new__.__doc__[/color][/color][/color]
'T.__new__(S, ...) -> a new object with type S, a subtype of T'[color=blue][color=green][color=darkred]
>>> list.__class__.__doc__[/color][/color][/color]
"type(object) -> the object's type\ntype(name, bases, dict) -> a new type"[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
  #2  
Old March 16th, 2006, 03:25 PM
Steven Bethard
Guest
 
Posts: n/a
Default Re: Python Documentation Standards

Colin J. Williams wrote:[color=blue]
> Doc strings provide us with a great opportunity to illuminate our code.
>
> In the example below, __init__ refers us to the class's documentation,
> but the class doc doesn't help much.[/color]

It doesn't?
[color=blue][color=green][color=darkred]
>>> print list.__doc__[/color][/color][/color]
list() -> new list
list(sequence) -> new list initialized from sequence's items

What is it you were hoping to see in constructor documentation?

STeVe
  #3  
Old March 16th, 2006, 04:05 PM
Duncan Booth
Guest
 
Posts: n/a
Default Re: Python Documentation Standards

Steven Bethard wrote:
[color=blue]
> Colin J. Williams wrote:[color=green]
>> Doc strings provide us with a great opportunity to illuminate our code.
>>
>> In the example below, __init__ refers us to the class's documentation,
>> but the class doc doesn't help much.[/color]
>
> It doesn't?
>[color=green][color=darkred]
> >>> print list.__doc__[/color][/color]
> list() -> new list
> list(sequence) -> new list initialized from sequence's items
>
> What is it you were hoping to see in constructor documentation?
>
> STeVe[/color]

How about this?:
[color=blue][color=green][color=darkred]
>>> print list.__doc__[/color][/color][/color]
list() -> new list
list(sequence) -> new list initialized from sequence's items
See http://docs.python.org/lib/built-in-funcs.html#l2h-44

although it would be better if the online docs had a more permanent looking
anchor.
  #4  
Old March 17th, 2006, 11:15 PM
Colin J. Williams
Guest
 
Posts: n/a
Default Re: Python Documentation Standards

Steven Bethard wrote:[color=blue]
> Colin J. Williams wrote:
>[color=green]
>> Doc strings provide us with a great opportunity to illuminate our code.
>>
>> In the example below, __init__ refers us to the class's documentation,
>> but the class doc doesn't help much.[/color]
>
>
> It doesn't?
>[color=green][color=darkred]
> >>> print list.__doc__[/color][/color]
> list() -> new list
> list(sequence) -> new list initialized from sequence's items
>
> What is it you were hoping to see in constructor documentation?
>
> STeVe[/color]
You are right, I didn't dig far enough.

Colin W.
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles