In article <[email protected]>,
Igor Korot <[email protected]> wrote:
> I can do it this way:
>
> >>> testlist = test.split(',')
> >>> print testlist[2]
> my
>
> but it will needlessly creates a list on which I will access by the index.
Stop worrying about needlessly creating lists. Write the code in a way
that works and is easy to understand. If it turns out that it's not
running fast enough, then you can go back and optimize.
BTW, for those of you into code golf:
>>> line = '192.168.1.6 > 192.168.1.7: ICMP echo request, id 100, seq
200, length 30'
>>> dict((k,int(v)) for k,v in (s.split() for s in line.split(', ')[1:]))
{'length': 30, 'id': 100, 'seq': 200}
--
https://mail.python.org/mailman/listinfo/python-list