Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7162963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:49:17+00:00 2026-05-28T13:49:17+00:00

This is my python script that gives me an exception like this IndexError: index

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:49:18+00:00Added an answer on May 28, 2026 at 1:49 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a python script that takes record data like this
I'm working on a Python script that transforms this: foo bar Into this: [[Component
I have a Python script that is running a few ls commands. This script
I'm trying to write a python script that packages our software. This script needs
So I've got a directory that looks something like this: home\ setup.py some_python_file.py ext\
I received this python script that generates a file checksum: import sys,os if __name__==__main__:
This is the first Python script I've tried to create. I'm reading a xml
I have a python script the runs this code: strpath = sudo svnadmin create
In my editor (notepad++) in Python script edit mode, a line ## is this
I tried running a python script: print Hello, World! And I get this error:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.