A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/351655.html below:

Documenting properties

Documenting propertiesPaul McNett p at ulmcnett.com
Tue Sep 27 14:18:22 EDT 2005
Lasse Vågsæther Karlsen wrote:
> So, my question is, is there a way to get __doc__ support for
> properties, in effect, use the """xxx""" syntax for documenting properties.

Yes, the property() function accepts a doc argument, as in:

property(fget, fset, fdel, doc)

ex:
MyProp = property(_get, _set, None, "This will show up in __doc__")


> Is the preferred way to use """xxx""" or # to document ?

# is for source code commenting (audience is the person reading your
code). """x""" is for documenting your API (audience is the person using
your code). They are quite different.


> Whatever is preferred, what's the upside/downsides of the two beyond
> what I just explained?

Nothing really, but something handy to keep in mind is that the string
literal ("""x""") can be used to block out huge sections of code during
testing, where you'd have to put a # in front of every line otherwise.

-- 
Paul McNett
http://paulmcnett.com
http://dabodev.com



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4