On Wed, Nov 30, 2016 at 7:33 PM, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Wed, 30 Nov 2016 18:56:21 +0530, g thakuri <gbpa...@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 ? > > -- https://mail.python.org/mailman/listinfo/python-list