critique this little script, if you like
John Salerno
johnjsal at NOSPAMgmail.com
Mon May 1 10:37:47 EDT 2006
Roel Schroeven wrote:
> But watch out with leading backslashes, as in
>
> subdirs = [r'\cgi-bin', r'\images', r'\styles']
>
> os.path.join will assume they are meant to be absolute paths, and will
> discard all previous components:
>
> >>> os.path.join('base', 'subdomain', r'\images')
> '\\images'
>
> In fact I think it's best to specify components without leading or
> trailing backslashes (unless you really want an absolute path):
>
> >>> os.path.join('base', 'subdomain', 'images')
> 'base\\subdomain\\images'
Yeah, I made the list of subdirectories just strings, like 'cgi-bin' and
took out the backslash. Then I used os.path.join to create those
subdirectories on the end of the main directory. It always amazes me how
posting here can lead to little tweaks that really clean up my code. :)
More information about the Python-list
mailing list