python parsing suggestion

Lorenzo Sutton lorenzofsutton at gmail.com
Mon May 30 12:13:49 EDT 2016


Hi,

On 30/05/2016 09:34, Ganesh Pal wrote:
> Hi ,
>
> Trying to extract the '1,1,114688:8192' pattern form the below output.
>
> pdb>stdout:
> '3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192)
> --\n3aae5d0-1:
> magic         0xdeaff2fe         mark_cookie
> 0x0000000000000000\ngpal-3aae5d0-1:         super.status
> 3        super.cookie          390781895\ngpal-3aae5d0-1:
>  cg_xth                  0

What parts of the string (i any) can we assume to always be the same?

>
> 1.  Is parsing with  stdout.strip().split('\n')[0].split()[6][:-1]
> sufficient do I need to add extra check ? it looks fine for me though.
>
> 2.  Better ways to achieve the same output  we need to parse is a string
>
> 3. Is re.search(r'(\d+),(\d+),(\d+):(\d+)', parent_block) needed ?  I
> added as an extra check ,any ideas on the same
>
>
> Regards,
>
> Ganesh
>



More information about the Python-list mailing list