Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > docstrings for data fields

Reply
Thread Tools

docstrings for data fields

 
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      05-03-2012
Hi!

My class Foo exports a constant, accessible as Foo.MAX_VALUE. Now, with
functions I would simply add a docstring explaining the meaning of this,
but how do I do that for a non-function member? Note also that ideally,
this constant wouldn't show up inside instances of the class but only
inside the class itself.

There are decorators for static functions or class functions, similarly
there is one for instance properties but there isn't one for class
properties. Would that be a useful addition?

Uli
 
Reply With Quote
 
 
 
 
mblume
Guest
Posts: n/a
 
      05-03-2012
Am Thu, 03 May 2012 14:51:54 +0200 schrieb Ulrich Eckhardt:

> Hi!
>
> My class Foo exports a constant, accessible as Foo.MAX_VALUE. Now, with
> functions I would simply add a docstring explaining the meaning of this,
> but how do I do that for a non-function member? Note also that ideally,
> this constant wouldn't show up inside instances of the class but only
> inside the class itself.
>
> There are decorators for static functions or class functions, similarly
> there is one for instance properties but there isn't one for class
> properties. Would that be a useful addition?
>
> Uli


Docstring for Foo?


>>>
>>> class Foo:

.... """ exports a FOO_MAX value """
.... FOO_MAX = 42
....
>>>
>>>
>>>
>>>
>>> help(Foo)

Help on class Foo in module __main__:

class Foo
| exports a FOO_MAX value
|
| Data and other attributes defined here:
|
| FOO_MAX = 42

>>> Foo.FOO_MAX

42
>>>
>>>
>>>



HTH
Martin
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicate docstrings Steven Bethard Python 2 02-19-2005 01:04 PM
Re: Unicode docstrings in PyMethodDef? Craig Ringer Python 1 12-10-2004 11:38 PM
Unicode docstrings in PyMethodDef? Craig Ringer Python 0 12-08-2004 05:43 AM
docstrings vs language comments Sridhar R Python 2 06-21-2004 05:17 PM
docstrings for module variables / pydoc Nuff Said Python 0 05-05-2004 03:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57