[Tutor] Pythonese/Efficiency/Generalese critique please

Javier Ruere javier at ruere.com.ar
Sun Jun 5 03:17:37 CEST 2005

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):

   Though it is quite distant, there is an else statement which makes 
the if construct a requierement.


More information about the Tutor mailing list