[Tutor] Regex for Filesystem path

Sarfraaz Ahmed sarfraaz at gmail.com
Tue Nov 6 13:13:23 EST 2018


Hello,

There are specific operating system, path related modules in Python for
handling these scenarios.

You could try looking at os.path module.

On Tue, Nov 6, 2018 at 11:16 PM Asad <asad.hasan2004 at gmail.com> wrote:

> Hi all ,
>
>         Can you provide some advice and code for the following problem :
>
> I have a logfile to check for errors :
>
> /a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log
>
> f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' )
> st1 = f3.readlines ()
>
> from the above log I extract the directory location to determine the
> location of  another log  using the following regular expresssion:
>

Specifically, try exploring "dirname" function of os.path module. That
might come in handy for your situation.

-- 
        Thanks
               -- Sarfraaz Ahmed


More information about the Tutor mailing list