Out-denting multiline comments

Delaney, Timothy tdelaney at avaya.com
Tue Aug 13 02:09:12 CEST 2002


> I may just try coding this up and seeing if it works ;)

import inspect

class autodoc (type):

    def __init__(cls, name, bases, dict):
        super(autodoc, cls).__init__(name, bases, dict)
        cls.__doc__ = inspect.getdoc(cls)

__metaclass__ = autodoc

class A:
    """
    First line.
    
    Second line.
        Third line (indented)
    """

print A.__doc__

---------- Run ----------
Traceback (most recent call last):
  File "...\getdoc.py", line 11, in ?
    class A:
  File "...\getdoc.py", line 7, in __init__
    cls.__doc__ = inspect.getdoc(cls)
TypeError: readonly attribute

:(

Tim Delaney




More information about the Python-list mailing list