Thanks for the critique Kent On Jun 4, 2005, at 6:54 PM, Kent Johnson wrote:
> Lee Cullens wrote: > > >> Pythonese/Efficiency/Generalese critique please >> >> I'm new to Python and as an exercise created a little utility module. >> I'm learning from the O'Reilly books and updating that understanding >> from the 2.4 documentation. >> >> I would appreciate any comments you see fit to offer. >> >> > > I find the nested functions confusing myself; is there a reason > they are nested? If they can stand alone I would make them separate > top-level functions with names starting with _ to indicate that > they are private. > > I did so first for a visual indication of use and relation (eyes of the beholder thing) and second to simplify scope. The latter though is a mute point since (I believe) the scope is the same either way, and my structure does add a little baggage to the recursion which is a negative. Your point is well taken. > dlst = os.listdir(pname) > if len(dlst): > for dlf in dlst: > > There is no need for the if(dlst); if the list is empty the > iteration will do nothing. You can write this as > for dlf in os.listdir(pname): > > Something I wrestled with - but as I needed to recognize an empty directory I needed something to facilitate such ( the for else was no help) so that is what I came up with and still don't see a way around. > Some blank lines would aid readability. For example before each > comment in cellpos() and before each elif in the main conditional > block. > > Good point. I've been letting all the bright colors in WingIDE lull me into forgetting others may see just b&w. > Do you know there is a csv module that helps to read and write csv > files? It will take care of escaping " in your filenames, if such a > thing is possible... > > No, I didn't know. If I do something like this seriously I'll check it out Thanks again, Lee C > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor