Path: csiph.com!weretis.net!feeder9.news.weretis.net!panix!.POSTED.2602:f977:0:1::1!not-for-mail From: pa@see.signature.invalid (Pierre Asselin) Newsgroups: comp.lang.python Subject: staticmethod(cls) Date: Thu, 4 Sep 2025 19:28:53 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <109cp9l$f41$1@reader1.panix.com> Injection-Date: Thu, 4 Sep 2025 19:28:53 -0000 (UTC) Injection-Info: reader1.panix.com; posting-host="2602:f977:0:1::1"; logging-data="15489"; mail-complaints-to="abuse@panix.com" User-Agent: tin/2.6.4-20241224 ("Helmsdale") (NetBSD/10.1 (amd64)) Xref: csiph.com comp.lang.python:197554 For reasons I won't go into I ended up defining classes inside of a class body. That's not in the manual, but I see no reason it would fail. But then, I accidentally decorated the inner classes with @staticmethod! It didn't break anything, but it had an interesting side effect: help() and pydoc on the outer class shows the docs of the inner class members. Normally only the inner classes are listed, not their contents. Here's a minimal example. ---------------------------------------------------------------------- class Outer: '''Outer class''' def outer_method(self): '''outer method''' class Inner0: '''Inner class''' def inner_0(instance): '''inner method, not seen by pydoc.''' @staticmethod class Inner1: '''Inner class passed through staticmethod()''' def inner_1(instance): '''inner method, visible to pydoc !''' ---------------------------------------------------------------------- Save and run pydoc, or import and run help(_module_.Outer). Now that's *seriously* not-in-the-manual. I won't rely on that behavior, plus the expanded documentation is a bit too much, but I'm curious as how that interaction between staticmethod() and help()/pydoc came about. -- pa at panix dot com