[Distutils] Copying entire directory

P.J. Eby pje at telecommunity.com
Wed Oct 6 19:26:22 CEST 2010


At 07:06 PM 10/6/2010 +0200, Friedrich Romstedt wrote:
>2010/10/6 Fred Drake <fdrake at acm.org>:
> > On Wed, Oct 6, 2010 at 12:54 PM, Friedrich Romstedt
> > <friedrichromstedt at gmail.com> wrote:
> >> It's in my
> >> opinion always a good idea to try to avoid hard-coding directory
> >> separators (/), and to use os.path.join() instead.
> >
> > Distutils specifically wants "/" rather than the local platform's
> > separator, and takes care of conversion as needed.
>
>Sure, thanks for the correction!  Don't know if glob would need
>platform-specific separators, though?

glob accepts '/' on most platforms, but returns platform-specific 
separators.  For this application, though, it's simpler to just use 
['prefix/'+f for f in os.listdir('prefix')].

Or, if you like obfuscational, er, I mean, functional programming, 
you can user:

     map('prefix/'.__add__, os.listdir('prefix'))

;-)



More information about the Distutils-SIG mailing list