Hi All , Thanks it works for me . However the other issue is :
testdir = dirname(dirname("/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log")) /a/b/c/d/test dirpath = join(testdir, '28163133/22326541') print dirpath /a/b/c/d/test\28163133/22326541 * Why is it putting \ this breaks the unix path it should be: /a/b/c/d/test/28163133/22326541 ===> for unix platform logs \a\b\c\d\test\28163133\22326541 ===> for windows platform logs Please advice , Thanks, On Thu, N > ---------- Forwarded message ---------- > From: Alan Gauld <alan.ga...@yahoo.co.uk> > To: tutor@python.org > Cc: > Bcc: > Date: Wed, 7 Nov 2018 19:21:58 +0000 > Subject: Re: [Tutor] Regex for Filesystem path (Asad) > On 07/11/2018 15:56, Asad wrote: > > Hi All, > > > > I tired seems its not working as required : > > > > from os.path import dirname, join > > > > testdir = > dirname("/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log") > > Note that this will set testdir to > > /a/b/c/d/test/test_2814__2018_10_05_12_12_45 > > But you want the dir above that. > The easiest way (if this is always the case) is to just use > dirname() again: > > testdir = dirname(testdir) > > Which should result in: > > /a/b/c/d/test > > You could of course do it in one line as > > myPath = "/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log" > testdir = dirname( dirname(myPath) ) > > Which is nicer than my original suggestion of using > chdir and relative paths :-) > > -- > 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 > > > > > > > ---------- Forwarded message ---------- > From: Zachary Ware <zachary.ware+py...@gmail.com> > To: > Cc: tutor <tutor@python.org> > Bcc: > Date: Wed, 7 Nov 2018 13:23:15 -0600 > Subject: Re: [Tutor] Displaying Status on the Command Line > On Wed, Nov 7, 2018 at 1:17 PM Alan Gauld via Tutor <tutor@python.org> > wrote: > > In Python 3 there are parameters to print() > > > > while someProcess(): > > time.sleep(1) > > print('.', end='', sep='') # no newline and no spaces > > You'll also want `flush=True` here to avoid having your dots buffered > until end-of-line. > > -- > Zach > > _______________________________________________ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > -- Asad Hasan +91 9582111698 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor