are docstrings for variables a bad idea?

jelle jelleferinga at gmail.com
Fri Apr 21 06:36:04 EDT 2006


That's basically the idea...
Often i find myself annotating what variables actually stand for, so to
refer back to the code in half a year or so.

 # check if ID's or coords
self.pointIDs = ptIDs
self.coords   = [tuple(RS.PointCoordinates(i)) for i in ptIDs]

# map ids/coords and coords/ids
self.pointID_2_Coord, self.coord_2_pointID = {}, {}
for id, coord in zip(self.pointIDs,self.coords):

    self.coord_2_pointID[coord] = id
    self.pointID_2_Coord[id]    = coord

# initiate kdtree
self.kdTREE = kdtree.kdtree(3)
for i in self.coords:
    self.kdTREE.addPoint(i)

# break down interfaceCrvID
self.segments = list(RS.ExplodeCurves(interfaceCrvID))

# dictionary with a midpoint for each segment
self.segmentCoords = {}
for i in self.segments:
    self.segmentCoords[i] = list(RS.CurveMidPoint(i))

and so on...
Please don't say that naming variables properly suffices for any
skilled programmer... really...

When programming a more complex class, it would be quite helpful that
these annotations would pop-up as a docstring.
Often I find myself referring back to a module containing the class to
read back what data the variable holds exactly. A time consuming
activity that could be seriously sped up by a proper IDE
(I'm on SPE, thanks Stani!)

Would that make sense to anyone?

cheers,

-jelle




More information about the Python-list mailing list