473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Documenting properties

I notice that if I use this syntax:

def classname:
...
##
# closes the database connection and releases the resources.
def close(self):
....

##
# Returns a list of fields
fields = property(....)

then doing:

help (classname)

then the text is listed for the property and the method, whereas if I do
this:

classname.close.__doc__

then nothing is listed, and to get that I have to use the """.."""
syntax to document:

def close(self):
"""closes the datab..."""
....

then classname.close.__doc__ shows the text.

So, my question is, is there a way to get __doc__ support for
properties, in effect, use the """xxx""" syntax for documenting properties.

Is the preferred way to use """xxx""" or # to document ?
Whatever is preferred, what's the upside/downsides of the two beyond
what I just explained?

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Sep 27 '05 #1
2 1412
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
Sep 27 '05 #2
Paul McNett wrote:
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.


Except, of course, code that contains string literals with triple
quotes. And with a good editor, it's not too difficult to insert a # in
front of hundreds of lines (:%s/^/#/g).

Gerrit.

--
Temperature in Luleå, Norrbotten, Sweden:
| Current temperature 05-09-27 20:19:54 9.8 degrees Celsius ( 49.7F) |
--
Det finns inte dåligt vÀder, bara dåliga klÀder.
Sep 27 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian Dam Pedersen | last post by:
Hi Group I'm trying to figure out the proper way to document object properties created with property() using the LaTeX styles coming with python. The closest thing seems to be...
5
by: Isaac Rodriguez | last post by:
Hi, Are there any standarized ways of documenting Python code? When I check the __doc__ attribute of the standard modules, the results are kind of plain. Is everyone using this style? Since...
6
by: Jeremy Wallace | last post by:
I have a ton of queries that I need users to be able to view. I'd like to have them viewed in a datasheet-view form instead of directly, so that I can keep the users from futzing with the data. ...
17
by: Jelmer | last post by:
Hi, I am mildly familiar with ms access developement and I have been asked to port and document a ms access app. I expect the porting (97 to XP) to be fairly straightforward. However documenting...
1
by: strauss.sean | last post by:
I have been asked to begin documenting the ongoing development and changes to a database that I maintain. Not the entry of data; this is about the changes to how tables are restructured, and any...
13
by: Jeff Rodriguez | last post by:
What sort of documentation do you do on your code? I've never done any code development on a big project and I want to start documenting my code in a way that makes sense, is easy to understand,...
1
by: Brett | last post by:
I'd like to have all of my documentation in one place. I use the following for documenting code: - attributes for certain types of documentation - use of the C# generated inline XML...
8
by: Spleenwort | last post by:
With regard to XML comments in c#. I think that #regions should be self-documenting relative to XML comments or that a <region> tag should be defined and auto-inserted when you type #region...
2
by: sajithamol | last post by:
What is a Self Documenting Code? wheather java is a self documenting code?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.