[Python-Dev] Re: [PEP 224] Attribute Docstrings

M.-A. Lemburg mal at lemburg.com
Mon Aug 28 15:03:11 EDT 2000


Aahz Maruch wrote:
> 
> [p&e]
> 
> In article <39AAA306.2CBD5383 at lemburg.com>,
> M.-A. Lemburg <mal at lemburg.com> wrote:
> >
> >class A:
> >    " Base class for database "
> >
> >    x = "???"
> >    " name of the database; override in subclasses ! "
> >
> >    y = 1
> >    " run in auto-commit ? "
> >
> >class D(A):
> >
> >    x = "mydb"
> >    """ name of the attached database; note that this must support
> >        transactions
> >    """
> >
> >This will give you:
> >
> >A.__doc__x__ == " name of the database; override in subclasses ! "
> >A.__doc__y__ == " run in auto-commit ? "
> >D.__doc__x__ == """ name of the attached database; note that this must support
> >        transactions
> >    """
> >D.__doc__y__ == " run in auto-commit ? "
> >
> >There's no way you are going to achieve this using dictionaries.
> 
> Maybe I'm dense, but what about
> 
> A.__docs__['x'] == " name of the database; override in subclasses ! "
> A.__docs__['y'] == " run in auto-commit ? "
> D.__docs__['x'] == """ name of the attached database; note that this must support
>         transactions
>     """
> D.__docs__['y'] == " run in auto-commit ? "
> 
> If D.__doc_y__ or D.__docs__['y'] is a reference to A.__docs__['y'],
> then it's a reference either way.  Conversely, if it's *not* a
> reference, there's *definitely* no problem.

Ok, some questions:

How would this be done for mixin classes ? 

What if you change the base classes of D after creation of D ?

How would D.__docs__ get the information about A's y attribute
and when ?

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/




More information about the Python-list mailing list