Re: Better way / regex to extract values form a dictionary

2018-07-22 Thread Thomas Jollans
On 21/07/18 14:39, Ganesh Pal wrote: >> The dictionary is irrelevant to your question. It doesn't matter whether >> the path came from a dict, a list, read directly from stdin, an >> environment variable, extracted from a CSV file, or plucked directly from >> outer space by the programmer. The proc

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
> The dictionary is irrelevant to your question. It doesn't matter whether > the path came from a dict, a list, read directly from stdin, an > environment variable, extracted from a CSV file, or plucked directly from > outer space by the programmer. The process remains the same regardless of > wher

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2018 17:07:04 +0530, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' > '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' > '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failur

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Paul Moore
def return_filename_test_case(filepath): filename = os.path.basename(filepath) testcase = filename.partition('_')[0] return filename, testcase On 21 July 2018 at 12:37, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELL

Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
I have one of the dictionary values in the below format '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failures.log' I need to extract the file name in the path example, say