On 06/11/2018 19:47, Cameron Simpson wrote: > It is better to just construct the required path. Chdir there requires a > chdir back, and chdir affects all the relative paths your programme may > be using. > > I'd use os.path.dirname to get '/a/b/c/d/test' and then just append to > it with os.path.join to contruct each directory path.
That was my original thought but the OP had his long path one below test so would need to strip one level off the dirname result. That's why I opted for chdir as the simplest solution(albeit not very efficient) > Do not use ctime, it is _not_ "creation" time. It is "last change to > inode" time. It _starts_ as creation time, but a chmod or even a > link/unlink can change it: anything that changes the metadata. Good catch, I should have known that. My bad. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor