[Tutor] Pythonese/Efficiency/Generalese critique please
Kent Johnson
kent37 at tds.net
Sun Jun 5 03:54:55 CEST 2005
Lee Cullens wrote:
> On Jun 4, 2005, at 6:54 PM, Kent Johnson wrote:
>> 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.
Ah right, I missed that.
>> 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.
I have syntax highlighting but I still use a lot of vertical white space to divide the code into small sections.
Kent
More information about the Tutor
mailing list