This is my python script that gives me an exception like this
IndexError: index out of range: 202252
if I put the 900000 to something smaller it works great. The function randint works with a lot of bigger numbers and that is not the place where the exception is thrown the exception is thrown at for q in range(long(fromline),long(fromline)+500L): this line, I think I has some problems with the long int conversions or some kind of data-type overflow.
fromline = random.randint(1,900000)
for q in range(long(fromline),long(fromline)+500L):
if (len(str(lines[fromline+q])) < 3:
print "blabla"
EDIT
#read the lines from file
f = open("asd.txt")
lines = f.readlines()
f.close()
# print "if I uncoment this, then exception is thrown" +str(len(lines))
if I do this
print lines[1]
print lines[100000]
…
it works just fine, I am really confused about this , I have never seen similar problem like this
EDIT
I find what exactly is my problem, please see my answer
I find my problem !
well thanks for all of you for the help, I tried this in pure python script and it is working fine. But the problem is that the spinet I show to you is just a part of one very big script that runs on phones. YES the python part is okey, I was searching the problem in python script but it is not there. The problem is in the limitations of the phone, namelly the 65536 lines is the limitation of few variables that I am using.For example when more then 65536 lines is put in the lines variable then the IndexError is thrown.
I hope this will help to someone who uses monkeyrunner with python.
As a summary when you write a python script that runs on phone (for example with monkeyrunner) always have in mind that some things will not work as you expected and some scripts that works fine on pc will NOT work when you run them on phone