473,732 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why not just show the out-of-range index?

Every Python programmer gets this message occasionally:

IndexError: list index out of range

The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are. Why does it force you to
determine that information for yourself when it could save you a step
and just tell you? This seems like a "no-brainer" to me. Am I missing
something?

Dec 4 '06 #1
85 4301
Russ wrote:
Every Python programmer gets this message occasionally:

IndexError: list index out of range

The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are. Why does it force you to
determine that information for yourself when it could save you a step
and just tell you? This seems like a "no-brainer" to me. Am I missing
something?
I think you have a point. I am curious to see how far people are willing
to go to defend this omission. It promises to be entertaining.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Dec 4 '06 #2

James Stroud wrote:
Russ wrote:
Every Python programmer gets this message occasionally:

IndexError: list index out of range

The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are. Why does it force you to
determine that information for yourself when it could save you a step
and just tell you? This seems like a "no-brainer" to me. Am I missing
something?

I think you have a point. I am curious to see how far people are willing
to go to defend this omission. It promises to be entertaining.
Add "Syntax Error: invalid syntax" to the list ...

Dec 4 '06 #3
James Stroud wrote:
Russ wrote:
>Every Python programmer gets this message occasionally:

IndexError: list index out of range

The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are. Why does it force you to
determine that information for yourself when it could save you a step
and just tell you? This seems like a "no-brainer" to me. Am I missing
something?

I think you have a point. I am curious to see how far people are willing
to go to defend this omission. It promises to be entertaining.
I'm not sure that anybody is going to defend it as a deliberate omission.
Rather, they (like I) will encourage to OP to submit a patch that fixes the problem.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 4 '06 #4
Rather, they (like I) will encourage to OP to submit a patch that fixes the problem.
Now, that would be rather silly. I would have to familiarize myself
with the code for the Python interpreter, then send a patch to the
maintainers (and hope they notice it in their inboxes), while the
maintainers themselves could probably "fix" the problem in two minutes
flat. No thanks!

My suggestion is trivial to implement and would benefit every Python
programmer (even if only slightly), so I don't think it is too much to
ask for.

Dec 4 '06 #5

John Machin wrote:
James Stroud wrote:
Russ wrote:
Every Python programmer gets this message occasionally:
>
IndexError: list index out of range
>
The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are. Why does it force you to
determine that information for yourself when it could save you a step
and just tell you? This seems like a "no-brainer" to me. Am I missing
something?
>
I think you have a point. I am curious to see how far people are willing
to go to defend this omission. It promises to be entertaining.

Add "Syntax Error: invalid syntax" to the list ...
But at least if you're using IDLE, the point of syntax error
is highlighted.

When I was a programmer, I thought as a programmer,
I spake as a programmer and I understood as a programmer.
But when I became a User, I put away such childish things.

Dec 4 '06 #6

me********@aol. com wrote:
John Machin wrote:
Add "Syntax Error: invalid syntax" to the list ...

But at least if you're using IDLE, the point of syntax error
is highlighted.
Same when using the interactive interpreter, the point of syntax error
is highlighted with a caret. However the highlighting of WHERE is
useless to people who don't have a clue WHAT the error is, and it needs
a forensic guru to suss it out as for example Peter Otten did, only
yesterday:
"""
Are you perhaps mixing tabs and spaces?
>>def f():
.... print "hello" # four spaces before 'print'
.... return 42 # one tab before 'return'
File "<stdin>", line 3
return 42
^
SyntaxError: invalid syntax
"""

Dec 4 '06 #7
Russ wrote:
>Rather, they (like I) will encourage to OP to submit a patch that fixes the problem.

Now, that would be rather silly. I would have to familiarize myself
with the code for the Python interpreter, then send a patch to the
maintainers (and hope they notice it in their inboxes), while the
maintainers themselves could probably "fix" the problem in two minutes
flat. No thanks!
And I believe that answers your original question.

PS: begging for a fix on comp.lang.pytho n is even less likely to get the
developer's attention than posting a patch. They listen to patch submissions
much more than comp.lang.pytho n. At the very least, you should submit a bug
report even if you don't want to take the opportunity to learn how to fix it
yourself.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 4 '06 #8

John Machin wrote:
me********@aol. com wrote:
John Machin wrote:
Add "Syntax Error: invalid syntax" to the list ...
But at least if you're using IDLE, the point of syntax error
is highlighted.

Same when using the interactive interpreter, the point of syntax error
is highlighted with a caret. However the highlighting of WHERE is
useless to people who don't have a clue WHAT the error is, and it needs
a forensic guru to suss it out as for example Peter Otten did, only
yesterday:
"""
Are you perhaps mixing tabs and spaces?
>def f():

... print "hello" # four spaces before 'print'
... return 42 # one tab before 'return'
File "<stdin>", line 3
return 42
^
SyntaxError: invalid syntax
"""
Well, more information would be better, but at least it's
not as bad as Windows:

Application xxx could not be started because a
required file could not be found. I know the name
of the file but I am not going to tell you what
it is.

Dec 4 '06 #9
Jean-Paul Calderone wrote:
And I have some laundry that I would like you to do for me. Let me know
when a convenient time for you to pick it up would be.
What that has to do with this thread escapes me, but since you
apparently have nothing better to do than track down information that
should have been provided to you, it's no wonder you don't have enough
time to do your own laundry.

When you call information to get a phone number, do you first ask if
they have the number, then call back a second time to get it if the
answer is yes?

If a policemen gives you a speeding ticket, do you expect him to tell
you how fast he thinks you were going, or are you content to wait for
the court date?

Get your mother to do your laundry -- after she dresses you in the
morning.

Dec 4 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1201
by: Yermat | last post by:
Hi all, I just want to be sure that I have really understand what classless means... Can you look at the following "test" function and tell me if this is what you would have called classless programmation ? thanks ! -- Yermat
2
8233
by: Mark | last post by:
Hi, I need to be able to have five different links and when when someone clicks to show row 2, row 1 automatically hides. Right now all i can figure out is a link that will show but then you have to click the same link to hide. I want to be able to turn off a row when another row is clicked on to show? Can someone help?
2
12189
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow { display: none; }
15
20748
by: Lee | last post by:
Often times, I do not want to specify the width of a div. Rather, I just want it to expand to be just wide enough to enclose its contents. Since this is how tables behave, I tried setting "div {display: table;}" and it worked - but only in firefox, but not in IE6. Are there any alternatives? Am I alone in needing this type of functionality? Thank You.
1
1988
by: Adil Bohoudi | last post by:
Hi all, i'm using a datagrid to show somedata retrieved from an sql-server 2000. this datagrid contains two columns a startdate and an enddate column. i used a storedprocedure to get both dates. but when i use the following code: datagrid.datasource = selDates() datagrid.bind()
3
20714
by: Gary | last post by:
Hi, I have my main form1 and I want to close it and then show form2, in VB6 I used the following code... unload me form2.show in VB.net I got this far
4
1064
by: Cc | last post by:
I have a mdi container , added panel(dock fill). when I tr show a form it didn't come out(no error) , it's only show out when I show as showdialog. how do I solve this, cause I don't want the form show as showdialog.
12
2808
by: Kevin | last post by:
In VB6 I have this in frmMain: Private sub Button1_Click() frmSecondOne.Show me.Hide End Sub and then in frmSecondOne: Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
12
2212
by: lawrence k | last post by:
I've a form that starts off like this: <form method="post" action="profile.php? id=5&formName=my_story_edit.htm" enctype="multipart/form-data"> <p>Email address:<br /> <input type="text" name="totalFormInputs" value="lawrence@krubner.com" /></p>
0
8944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9306
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.