foo = 'eggs'
foo[:1] # the same is foo[0]
foo[-1:] # the same is foo[-1]
Is there any advantage of one of these ways?
I ran into this over here https://hg.python.org/cpython/file/3.4/Lib/xml/etree/ElementPath.py#l254
UPD. Can you go to the link? The variable path is a string there. And I was confused, why they were using a slice instead of a concreate index.
if path[-1:] == "/":