-2

Possible Duplicate:
Good Primer for Python Slice Notation

hxs = HtmlXPathSelector(response)
sites = hxs.select('//table/tr')[1:]

Here i understand that scrape from second row. But i was not able to find any links to understand advanced topics on that "[1:]". Please share me any reference links

Community
  • 1
  • 1
Joshua
  • 17
  • 3
  • 4
    It's called "slicing". See here: http://stackoverflow.com/questions/509211/good-primer-for-python-slice-notation – Peter Jul 18 '12 at 06:58

1 Answers1

0

It is used to extract slices from arrays/lists.

It can be used [start:end[:ratio]]

ration is optional, and it is the jump -- ratio=2 means to extract even indexes.

if end is negative, start to count from the end of the list that number.

[1,2,3,4][1:-1:2]

means

[2]
alinsoar
  • 15,386
  • 4
  • 57
  • 74