5

Following sample is taken from "Dive into python" book.

class MP3FileInfo(FileInfo): "store ID3v1.0 MP3 tags" tagDataMap = ... 

This sample shows documenting the MP3FileInfo, but how can I add help to MP3FileInfo. tagDataMap

3 Answers 3

4

The PEP 224 on attribute docstrings was rejected (long time ago), so this is a problem for me as well, sometimes I don't know to choose a class attribute or an instance property -- the second can have a docstring.

Sign up to request clarification or add additional context in comments.

Comments

1

Change it into a property method.

1 Comment

I wonder about this, since then you have to create explicit getter, setter and deleter (I want all three), only to have it behave normally. Is there a way to set default methods for these that simply wrap a class attribute?
0

Do it like this:

class MP3FileInfo(FileInfo): """Store ID3v1.0 MP3 tags.""" @property def tagDataMap(self): """This function computes map of tags. The amount of work necessary to compute is quite large, therefore we memoize the result. """ ... 

Note though you really shouldn't make a separate docstring if the attribute has only a one-line description. Instead, use

class MP3FileInfo(FileInfo): """Store ID3v1.0 MP3 tags. Here are the attributes: tagDataMap -- contains a map of tags """ tagDataMap = ... 

1 Comment

in my case attribute has public visibility - that is why help(tagDataMap) is what I want to get

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.