Simple code and suggestion
Ganesh Pal
ganesh1pal at gmail.com
Wed Nov 30 09:22:25 EST 2016
On Wed, Nov 30, 2016 at 7:33 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com>
wrote:
> On Wed, 30 Nov 2016 18:56:21 +0530, g thakuri <gbpal13 at gmail.com>
> declaimed
> the following:
>
> >Dear Python friends,
> >
> >I have a simple question , need your suggestion the same
> >
> >I would want to avoid using multiple split in the below code , what
> options
> >do we have before tokenising the line?, may be validate the first line any
> >other ideas
> >
> > cmd = 'utility %s' % (file)
> > out, err, exitcode = command_runner(cmd)
> > data = stdout.strip().split('\n')[0].split()[5][:-2]
> >
> 1) Where did "stdout" come from? (I suspect you meant just
> "out")
>
My bad it should have been out , here is the updated code
> cmd = 'utility %s' % (file)
> out, err, exitcode = command_runner(cmd)
> data = out.strip().split('\n')[0].split()[5][:-2]
>
> 2) The [0] indicates you are only interested in the FIRST
> LINE; if so,
> just remove the entire ".split('\n')[0]" since the sixth white space
> element on the first line is also the sixth white space element of the
> entire returned data.
>
>
Yes , I am interested only in the first line , may be we can test if we
have a line[0] before tokenising the line ?
>
>
More information about the Python-list
mailing list