473,385 Members | 1,356 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.

docstrings style question

I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""
I don't like the duplicated information: But the comment is attractive, and
the docstring self.__doc__ is already in use in the test log. I've read that
all modules and classes should have docstrings, but I don't really have
anything else to say, and each module contains only one class. I don't think
that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?

Steve.
Jan 10 '08 #1
6 1155
On Jan 9, 9:47 pm, "Steve Brown" <st...@mhomer.auwrote:
I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

I don't like the duplicated information: But the comment is attractive, and
the docstring self.__doc__ is already in use in the test log. I've read that
all modules and classes should have docstrings, but I don't really have
anything else to say, and each module contains only one class. I don't think
that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?

Steve.
I tend to be a bit skimpy with one-line comments for classes and
methods, but I think a more complete (""" style) comment is often
appropriate for the top of the file.

I'm sure you can think of more to say than "Temperature Sense Test."

What temperature? What kind of temperature sensor? What kind of test
is it, and why are you doing it? That may all be obvious in context,
but you've provided no context in your post. Also, if the module is of
any significant size, you might want to provide a clue about who wrote
it. Then, if someone has a question about it later, they will know who
to ask.
Jan 10 '08 #2
Steve Brown wrote:
I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""
I don't like the duplicated information: But the comment is attractive, and
the docstring self.__doc__ is already in use in the test log. I've read that
all modules and classes should have docstrings, but I don't really have
anything else to say, and each module contains only one class. I don't think
that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?
since you already seem to cater to your audience (clearly marked
comments for people browsing the code, brief docstrings for the test
log), I don't really see why you should change anything.
I've read that all modules and classes should have docstrings
if nobody's going to read them, there's no reason to add them. don't
treat generic style advice as dogma.

</F>

Jan 10 '08 #3
On Behalf Of Steve Brown
What do you think?
I think that comments are for maintainers, and docstrings are for users.

Some of the things I use comments for:
* Visually separate classes (using a syntax-highlighting editor)
* Explain algorithm choices
* Explain bug fixes so I don't later "fix" code back to the buggy version

Some of the things I use docstrings for:
* Describe interface (inputs/outputs)
* Sample usage

I personally don't use doctests, but that's one more use of docstrings.

Regards,
Ryan Ginstrom

Jan 10 '08 #4
Russ P. wrote:
On Jan 9, 9:47 pm, "Steve Brown" <st...@mhomer.auwrote:
>I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

I don't like the duplicated information: But the comment is attractive,
and the docstring self.__doc__ is already in use in the test log. I've
read that all modules and classes should have docstrings, but I don't
really have anything else to say, and each module contains only one
class. I don't think that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?
It's still duplicated information.
I tend to be a bit skimpy with one-line comments for classes and
methods, but I think a more complete (""" style) comment is often
appropriate for the top of the file.

I'm sure you can think of more to say than "Temperature Sense Test."
exactly my opinion
What temperature? What kind of temperature sensor? What kind of test
is it, and why are you doing it? That may all be obvious in context,
but you've provided no context in your post. Also, if the module is of
any significant size, you might want to provide a clue about who wrote
it. Then, if someone has a question about it later, they will know who
to ask.
I tend to mention the main use cases for test classes (especially) and also
a "human readable" description of what can happen (forgive me the missing
line breaks). Something like this:

class Test3(ar_test.AR_TEST):
"""Temperature Sense Test.
This class assures that the connection to the hardware sensor can be
established. It also checks a reference sensor that always reports a
certain value so that one can be sure correct data values are reported.
"""

hth
martin

--
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.

Jan 10 '08 #5
On Jan 10, 2008 12:47 AM, Steve Brown <st***@mhomer.auwrote:
I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""
I don't like the duplicated information: But the comment is attractive, and
the docstring self.__doc__ is already in use in the test log. I've read that
all modules and classes should have docstrings, but I don't really have
anything else to say, and each module contains only one class. I don't think
that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?
I recommend a careful reading of PEP 257.

You shouldn't waste your time creating (at best) decorative comments, like:
#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test""

Remember that comments have to maintained along with the rest of the
code, so unnecessary ones just create more work for you. Any time you
can replace a comment with self-explanatory code, you should.

Here's a vast improvement:

class TemperatureSenseTester(ar_test.AR_TEST):

--
Neil Cerutti <mr***************@gmail.com>
Jan 10 '08 #6

"Neil Cerutti" <mr********@gmail.comwrote in message
news:ma************************************@python .org...
On Jan 10, 2008 12:47 AM, Steve Brown <st***@mhomer.auwrote:
>I've got a series of modules which look like this:

#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""
I don't like the duplicated information: But the comment is attractive,
and
the docstring self.__doc__ is already in use in the test log. I've read
that
all modules and classes should have docstrings, but I don't really have
anything else to say, and each module contains only one class. I don't
think
that

"""Temperature Sense Test"""
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test"""

would be a real improvement.

What do you think?

I recommend a careful reading of PEP 257.

You shouldn't waste your time creating (at best) decorative comments,
like:
#************
#
# Temperature Sense Test
#
#************
class Test3(ar_test.AR_TEST):
"""Temperature Sense Test""

Remember that comments have to maintained along with the rest of the
code, so unnecessary ones just create more work for you. Any time you
can replace a comment with self-explanatory code, you should.

Here's a vast improvement:

class TemperatureSenseTester(ar_test.AR_TEST):

--
Neil Cerutti <mr***************@gmail.com>
Yes, I'm working in that direction. At present there is still code that
parses the test sequence to get the class name, but I'm rebuilding that.

However, there will still be sufficient information for some of the tests
to justify one doc string or comment as well as the class name.

Is it possible to get from an object to a class module doc string?

Something like self.class.module.__doc__ ?

I'm not able to do an assignment inside the test class, because I have
to keep that clean, but I can do assignments inside the parent test class.
Steve
Jan 11 '08 #7

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

Similar topics

2
by: Sridhar R | last post by:
When writing a python library, we can use docstrings for methods and functions that are part of API. But what about comments for non-API objects or python application code? For applications,...
0
by: Craig Ringer | last post by:
Hi folks I'm currently working on a fairly well internationalised app that embeds a Python intepreter. I'd like to make the docstrings translatable, but am running into the issue that the...
2
by: Steven Bethard | last post by:
I have two classes that implement the same interface, e.g. something like: class C(object): def foo(self): """Foo things""" ... def bar(self): """Bar things""" ... def baz(self):
6
by: Kamilche | last post by:
I have a large project that is getting complex, and I would like to print the docstrings without importing the modules. The only Python utility I could find references is apparently defunct and...
0
by: Edward Loper | last post by:
Epydoc 3 supports extracting information about Python modules by parsing. As a result, it can extract "docstrings" for variables. There are several possible ways these docstrings could be...
12
by: jelle | last post by:
That's basically the idea... Often i find myself annotating what variables actually stand for, so to refer back to the code in half a year or so. # check if ID's or coords self.pointIDs = ptIDs...
1
bartonc
by: bartonc | last post by:
You will be rewarded sooner than you think when you use docstrings to document your classes and functions. Whether you ever intend to publish your work or not, docstrings will help you in several...
0
by: tjhnson | last post by:
The topic of docstrings for variables has come up many times before. In fact, a PEP was proposed and rejected on this very topic. http://www.python.org/dev/peps/pep-0224/ When creating...
1
by: Infinity77 | last post by:
Hi All, I apologize in advance if my question sounds dumb. I googled back and forth but my google-fu today is not working very well... I have seen the new style Python html documentation, which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.