I would say it depends on the use case. The best practice is always to name things explicitly so you do not need docs (or comments). On that note, there was a movement called extreme programming (XP) in the late 90's that advocated use of no comments at all, amongst other things.
Anyway; having said that, I think docstrings have their place. If you are writing public API, and your user will look for the signatures, it is better to document. In that case, you might have to even be consistent and write docstrings for every single function/class, for the sake of uniformity and making your product look professional and polished, even if it seems redundant to do so. On the other hand, if your users are a small dev team working within a close group, use common sense and document where needed. Here, the rule of thumb would be - if your code can't explain what it is doing, use documentation. On Mon, May 3, 2021, 00:57 Justin Israel <justinisr...@gmail.com> wrote: > My take is that I want to see docstrings on public functions (which as > you pointed out are different from comments). > One added benefit of writing a docstring is that doc generators like > sphinx, and IDEs, can produce helpful type linking and hinting. So if your > function takes a certain type and returns a certain type, you may be able > to get links to those types for more information. Also docstrings are > helpful for an IDE to perform type hinting in python2. I know that in > python3 we gain proper language-level type annotations, but for now we have > to do it through comments and docstrings in python2. > > It may be subjective for a developer to think > that calculate_inverse(matrix) "obviously" accepts a numpy ndarray as its > input type, and then chooses not to document it in a docstring. But what if > there are different types that could be considered a matrix object and it > is really not so obvious to someone reading the docs or the signatures and > only sees that your api expects a "matrix"? Better to just use the > appropriate docstring formats to add type information, until everything is > python3 and you can do it all via type annotations. > > > On Mon, May 3, 2021 at 6:30 AM Rudi Hammad <rudiham...@gmail.com> wrote: > >> >> This not strictly related to maya but I wonder how you feel about it. >> In sumary, I found my self in similar situations as this: >> docstring example >> <https://stackoverflow.com/questions/33019955/should-you-always-document-functions-even-if-redundant-specifically-python> >> >> I think the link above isn't really answering what is was asked. >> He was asking about docstrings and people where responding to comments. I >> agree that unless necesarry your code shouldn't need any comments if you >> respect some programing princpiples. So you never find your self in long >> functions that requieres explanations with comments. >> >> But what about the docstring in that example? If you are methodic in your >> documentation and document everything, you will end up many times writing >> docstrings longer than the functions it self. I don't think it is something >> bad, just annoying. >> Also some programs generate automatically documentation for your api. For >> instance I use sphinx-doc and all exisiting docstrings are parsed and >> nicely documented automatically. >> >> what is your take on this? >> >> R >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to python_inside_maya+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/01a95b10-0d22-424d-9d10-b8642efbfab9n%40googlegroups.com >> <https://groups.google.com/d/msgid/python_inside_maya/01a95b10-0d22-424d-9d10-b8642efbfab9n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to python_inside_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2MmtAPei1x2rWGzPD6YkjqsTMdxNKBeGLt3-u0GgwMVw%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2MmtAPei1x2rWGzPD6YkjqsTMdxNKBeGLt3-u0GgwMVw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTbALUw%3D9vHd7E%2BSL2Vz_pqwQK4PKLMsuK%2BDF7kd8jzLQ%40mail.gmail.com.