str: Implement proper string (instead of byte string) indexing.

Also, support negative indexes.
This commit is contained in:
Paul Sokolovsky
2014-01-21 02:22:02 +02:00
parent 545591a696
commit 7380a83780
2 changed files with 13 additions and 3 deletions

View File

@@ -10,6 +10,17 @@ print('123' + "456")
print('123' * 5)
print('abc'[1])
print('abc'[-1])
try:
'abc'[100]
except IndexError:
print('caught')
try:
'abc'[-4]
except IndexError:
print('caught2')
# iter
print(list('str'))