In article <[EMAIL PROTECTED]>, "jelle" <[EMAIL PROTECTED]> wrote:
> When programming a more complex class, it would be quite helpful that > these annotations would pop-up as a docstring. I'm currently working with a OO database system that lets you attach a doc string not just to classes, but also to attributes, relationships, pretty much anything. It's very useful. That being said, I'm not sure how such a thing would work in Python. In what I'm used to, the doc strings are attached to the variable declarations in the class definition, so there's just one copy of the string per class. Python doesn't work that way. In Python, if I were to write: class GeographicCoordinate: def __init__ (self, lat, long): self.lat = lat "Latitude in degrees (positive North), per WGS84" self.long = long "Longitude in degrees (positive West), per WGS84" each *instance* of GeographicCoordinate gets a self.lat and a self.long created in it, with no relationship between the attributes of one instance and another. Where would the doc strings go? The only logical place would be to have one copy per instance, which would be very wasteful. On the other hand, since strings get interned, maybe it wouldn't be so bad. On the third hand, I guess the doc strings could get attached to the class's __slots__, which would immediately lead to more "but that's not what __slots__ was intended for" arguments :-) -- http://mail.python.org/mailman/listinfo/python-list