On Wed, 07 May 2008 23:29:27 +0000, Yves Dorfsman wrote: > Is there a way to do: > x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > x[0,2:6] > > That would return: > [0, 3, 4, 5, 6]
IMHO this notation is confusing. What's wrong with: [0]+x[2:6] > I am surprised this notation is not supported, it seems intuitive. A > concrete example of the sort of thing I want to do: > > p = file('/etc/passwd').readlines() > q = [ e.strip().split(':')[0,2:] for e in p ] > > (getting rid of the password / x field) This works and is clearer: [[0] + e.strip().split(':')[2:] for e in open('/etc/passwd')] -- Ivan -- http://mail.python.org/mailman/listinfo/python-list