Peter Hansen wrote:
> Kent Johnson wrote:
>> import path
>> files = path.path(pathToSearch).walkfiles(filename)
> 
> A minor enhancement (IMHO) (though I certainly agree with Kent's 
> recommendation here): since there is nothing else of interest in the 
> "path" module, it seems to be a fairly common idiom to do "from path 
> import path" and skip the doubled "path.path" bit.

Certainly it's your choice. I find most programs using path only reference 
path.path once, to create a starting path; other paths are created from that 
using files() or / etc. In this case it is less typing to say

import path
basePath = path.path(...)

instead of

from path import path
basePath = path(...)

from path import path only wins on number of chars if you reference path 
*three* times.

YMMV :-)

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to