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

R

Russ

Robert said:
No one is castigating the OP for bringing up the issue. His suggestion that his
time is worth more than that of anyone else, though, is drawing some ire.

I'm afraid that any such "suggestion" is purely in your own
imagination. My time? Do you think I am the only one who has
IndexErrors?
Fortunately, he seems to have backed off this position and seems amenable to
doing something more productive than posting here.

I made a simple suggestion to enhance the convenience and productivity
of Python, and I was attacked for even discussing it rather than
immediately doing it myself. WTF?
 
F

Fredrik Lundh

Russ said:
I'm afraid that any such "suggestion" is purely in your own
imagination.

"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 a couple of other posts with a similar tone. open source developers
tend to ignore people who use the "you're just a bunch of code monkeys"
intimidation approach, especially when combined with an undertone of
"what I'm proposing should be easy, and if it isn't, that's because
you're incompetent". claiming to talk for everyone else doesn't really
help, either.

I suggest doing what you should have done from the start; go to the
feature request tracker:

http://sourceforge.net/tracker/?group_id=5470&atid=355470

and click "suggest new".

</F>
 
R

Russ

Fredrik said:
"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!"

That is a perfectly reasonable statement. Forgive me if I
underestimated the difficulty of implementing the feature I suggested,
but I still don't think it would be difficult for the code maintainers
to implement. They are obviously familiar with the code, but I'm not!
and a couple of other posts with a similar tone. open source developers
tend to ignore people who use the "you're just a bunch of code monkeys"
intimidation approach, especially when combined with an undertone of
"what I'm proposing should be easy, and if it isn't, that's because
you're incompetent". claiming to talk for everyone else doesn't really
help, either.

Boy, some of you guys seem to have a very low self esteem, reading
insults where none exist. "Just a bunch of code monkeys"?!! Where in
the friggin' world did I say anything remotely resembling that? I
happen to be a proud "code monkey" myself, for crying out loud! And
excuuuuuuuuuuuuuse me for suggesting a minor new feature to enhance the
productivity of Python without implementing it myself! Geez!
 
R

Robert Kern

Russ said:
And
excuuuuuuuuuuuuuse me for suggesting a minor new feature to enhance the
productivity of Python without implementing it myself! Geez!

Like I said, no one is castigating you for making the request. It's been your
attitude afterwards that is the problem. You've been pointed to the productive
things you can do to resolve the issue that you have:

1. Submit a bug report.
2. Submit a patch.

Nothing is going to happen until you do one of these two things. Being more rude
(and yes, you are being incredibly rude and insulting) won't move things along.

--
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
 
R

Russ

Robert said:
Nothing is going to happen until you do one of these two things. Being more rude
(and yes, you are being incredibly rude and insulting) won't move things along.

I re-read the thread, and I don't see anywhere where I was rude except
in reply to rudeness by others. Sorry, but I haven't mastered the "turn
the other cheek" thing yet.

My suggestion that it would be much easier for the Python maintainers
than for me to implement the requested feature is just basic common
sense. I would have to spend many hours or days just to familiarize
myself with the code, but they are obviously already very familiar with
it. And they would probably have to spend nearly as much time checking
my patch as they would writing it themselves anyway.

By the way, your parenthical assertion that I am "being incredibly rude
and insulting" is itself an unwarranted and devious insult, and I will
not let you get away with it without being called on it. But I'm
willing to forget about it and move on, and I'll assume you are too.
 
R

Robert Kern

Russ said:
I re-read the thread, and I don't see anywhere where I was rude except
in reply to rudeness by others. Sorry, but I haven't mastered the "turn
the other cheek" thing yet.

Learn quickly if you are going to keep asking for other people's help.
My suggestion that it would be much easier for the Python maintainers
than for me to implement the requested feature is just basic common
sense. I would have to spend many hours or days just to familiarize
myself with the code, but they are obviously already very familiar with
it. And they would probably have to spend nearly as much time checking
my patch as they would writing it themselves anyway.

You're still missing the other side of the balance: how much the person wants
the feature. I simply don't care enough about the issue to put in the effort
that it would take me. You don't care enough, either, to put in the effort that
it would take you. That's fine. That's your judgment to make. What's
disrespectful is your expectation that you can make that judgment call for other
people. Just because it might take me less time to do it doesn't mean that I am
obliged to want it as much as you do.
By the way, your parenthical assertion that I am "being incredibly rude
and insulting" is itself an unwarranted and devious insult, and I will
not let you get away with it without being called on it.

As you wish. Insults are in the ear of the listener, not the speaker. With that
rule in mind, however, what I said is a simple statement of fact. If the
statement of facts insults you, I'm sorry. You are going to have a very
difficult time here.

You're also missing that *I'm trying to help you*. The way that you have been
acting, regardless of whether you think it is rude or not, will not convince
anyone to solve your problem.

In short, you've asked for a feature in the hope that someone will think it
important enough to do it themselves. No one who has read the thread does. At
least, not in the time frame since you've posted. That may change; in which
case, you should submit the bug report so that the core developers who didn't
read this thread (i.e. nearly all of them) will see it. Maybe they will be in a
small-feature-implementing mood and will want to implement it. If you don't
submit the bug report, odds are everyone will forget all about it.

Or you can take this as a learning opportunity, and make the fix yourself. Then
the next time you run into something like this (and I imagine that you will),
you can take the two minutes to fix it.
But I'm
willing to forget about it and move on, and I'll assume you are too.

Submit the bug report, and I will.

--
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
 
C

Carsten Haese

I re-read the thread, and I don't see anywhere where I was rude

Please allow me to break it down for you:

Your first reply on this thread, or second message, said:

"""
Now, that [submitting a patch that fixes the problem] 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.
"""

You may not have meant this to be rude, but it does come off as rude and
arrogant, and I'll explain to you why: In your first post you stated
that the feature seems like a no-brainer to you. That implies to the
reader that you might have the necessary skill to implement the feature
yourself, hence Robert's suggestion to submit a patch was, in the
context you gave yourself, neither unreasonable nor silly. I can see how
your calling a reasonable suggestion by a valuable community member
"silly" would be construed as rude and arrogant.

Hope this helps,

Carsten.
 
P

Paul McGuire

I think your biggest initial recoil to the response you got was in the
request that you submit a patch. You thought, "Geez, I just want one
friggin' error message changed, and they want me to learn the whole Python
development environment." Given your newbiness with Python, probably a
better response to you would be, "Submit this as a feature request at the SF
tracker page. If you really feel ambitious, put together a patch to go with
it, it will increase the likelihood of getting accepted about 50X."

A couple of other notes:
- The core developers do post here, but the real core Python development
discussions go on on the pydev mailing list.
- Please recognize that you did get at least one response from John Machin,
who scanned the code for this simple error message, and found that the
impact was actually in about a dozen places (not uncommon when peeling away
at the onion of source code, you've probably seen this yourself). This gave
all of us a better appreciation of the size of the effort required for what
initially seemed like a 30-second job. (BTW, there are *never* any 30-second
jobs, especially in a package the size of Python.)

So let me echo the effbot and ask that you submit this at the feature
request tracker page on SF - I think you've spent more time in posting to
this thread than it would have taken to submit this request. If you don't
want to learn the Python dev environment, that's fine, you might consider
composing a pydev mailing list submission making your case on the merits of
implementing some user-friendliness features, such as more explanatory error
messages. But the plain truth is, patches speak louder than words, on pydev
even moreso than c.l.py.

-- Paul
 
R

rurpy

Carsten said:
I re-read the thread, and I don't see anywhere where I was rude

Please allow me to break it down for you:

Your first reply on this thread, or second message, said:

"""
Now, that [submitting a patch that fixes the problem] 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.
"""

You may not have meant this to be rude, but it does come off as rude and
arrogant, and I'll explain to you why: In your first post you stated
that the feature seems like a no-brainer to you. That implies to the
reader that you might have the necessary skill to implement the feature
yourself, hence Robert's suggestion to submit a patch was, in the
context you gave yourself, neither unreasonable nor silly. I can see how
your calling a reasonable suggestion by a valuable community member
"silly" would be construed as rude and arrogant.

Thanks for explaining why the OP was rude. Having been
reading and listening to english for only a few decades
probably, I am sure the OP (and me too!) appreciates your
explanation of rudeness. It was really hard for me to see it
until you explained it so well. The great thing about c.l.p. is
how much one learns about non-Python things here.
(oops, I hope I wasn't rude by saying there were non-Python
things? I didn't mean to diminish Python in any way.)

Russ,
Please rememer that learning Python is not done overnight --
there are many different levels of knowlage and only the
most elite Pythonists have reached True Understanding.

Since there are many things you don't understand, it is
best you (and me too!) do not make suggrestions publically.
Infidels could read them and inplying that Python is not
perfect and you will undermine the spritual growth of
many other newbies.. Such dangerous sugggestions
should be made privately at the alter of Sourceforge, with
a lot of deep self-reflection and piety.

Until you achive greater understanding it is best if in public
you make sure that you write with the following in mind:
Python is perfect
Perl sucks
Static typing sucks
Python is faster than C
Quoting frequently from the holy Zen of Python is also
helpful. Please remember that many regulars here are
members of the holy priesthood because they have spent
many years studying the Python scriptures. Be as circumspect
in addressing them as you would be a medival knight or
Japanese samurai. Only by following their guidance with
complete devoutness and faith will you be able to achive
the deepest level of Python appreciation.

Hope this helps.
 
C

Carsten Haese

Carsten said:
Robert Kern wrote:

Nothing is going to happen until you do one of these two things. Being more rude
(and yes, you are being incredibly rude and insulting) won't move things along.

I re-read the thread, and I don't see anywhere where I was rude

Please allow me to break it down for you:

Your first reply on this thread, or second message, said:

"""
Now, that [submitting a patch that fixes the problem] 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.
"""

You may not have meant this to be rude, but it does come off as rude and
arrogant, and I'll explain to you why: In your first post you stated
that the feature seems like a no-brainer to you. That implies to the
reader that you might have the necessary skill to implement the feature
yourself, hence Robert's suggestion to submit a patch was, in the
context you gave yourself, neither unreasonable nor silly. I can see how
your calling a reasonable suggestion by a valuable community member
"silly" would be construed as rude and arrogant.

Thanks for explaining why the OP was rude. Having been
reading and listening to english for only a few decades
probably, I am sure the OP (and me too!) appreciates your
explanation of rudeness. It was really hard for me to see it
until you explained it so well. The great thing about c.l.p. is
how much one learns about non-Python things here.
(oops, I hope I wasn't rude by saying there were non-Python
things? I didn't mean to diminish Python in any way.)

Russ,
Please rememer that learning Python is not done overnight --
there are many different levels of knowlage and only the
most elite Pythonists have reached True Understanding.

Since there are many things you don't understand, it is
best you (and me too!) do not make suggrestions publically.
Infidels could read them and inplying that Python is not
perfect and you will undermine the spritual growth of
many other newbies.. Such dangerous sugggestions
should be made privately at the alter of Sourceforge, with
a lot of deep self-reflection and piety.

Until you achive greater understanding it is best if in public
you make sure that you write with the following in mind:
Python is perfect
Perl sucks
Static typing sucks
Python is faster than C
Quoting frequently from the holy Zen of Python is also
helpful. Please remember that many regulars here are
members of the holy priesthood because they have spent
many years studying the Python scriptures. Be as circumspect
in addressing them as you would be a medival knight or
Japanese samurai. Only by following their guidance with
complete devoutness and faith will you be able to achive
the deepest level of Python appreciation.

Hope this helps.

My sarcasm meter just exploded.

-Carsten
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Russ said:
I love Python, but every time I get an out-of-range error message, I
wonder why it didn't just tell me what the out-of-range index was and
what the allowable range was. Certainly that information must be
available to the exception handler, or how would it know that it is out
of range?

Yes, that is true. The information is readily available.

It's not true that it is "trivial" to fix, though: for every fix, there
ought to be a new test case also, and you have to run the test suite.
Depending on how fast a developer is, it may take between 30min and
1hour to get a fix implemented (for the list case alone, not counting
all the other sequences).

Even though I could fix it, I don't feel tempted to do so: I never had
this problem; in most cases of IndexError, it was very clear what the
problem was so I didn't need the additional information.

Regards,
Martin
 
R

Russ

Carsten said:
You may not have meant this to be rude, but it does come off as rude and
arrogant, and I'll explain to you why: In your first post you stated
that the feature seems like a no-brainer to you. That implies to the
reader that you might have the necessary skill to implement the feature
yourself, hence Robert's suggestion to submit a patch was, in the
context you gave yourself, neither unreasonable nor silly. I can see how
your calling a reasonable suggestion by a valuable community member
"silly" would be construed as rude and arrogant.

Hope this helps,

OK, fair enough. I shouldn't have called his suggestion "silly." When I
replied to him I honestly thought it was, but in retrospect I now see
that it wasn't. My mistake.

By the way, I consider myself a pretty good Python programmer, but I
haven't used C in many years, and I have no desire to ever use it -- or
even see it -- again. That's one of the reasons I use Python in the
first place. (I am fortunate enough to get to choose the language I
use.) I think it's unfortunate that Python is written in C, but I won't
get into that now. (And yes, I am aware of Jython, but I don't care
much for Java either.)
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Russ said:
My suggestion that it would be much easier for the Python maintainers
than for me to implement the requested feature is just basic common
sense. I would have to spend many hours or days just to familiarize
myself with the code, but they are obviously already very familiar with
it.

That is all true. However, you seem to be implying that therefore, it
is the Python maintainers who ought to fix this. That implication is
faulty. Not everything that somebody could do better than you should
be done by that other person - some things you have to do yourself
if you want to see them done.

All Python contributors (including the maintainers) are volunteers,
none of us is paid. Volunteers tend to do what they have fun doing
or what scratches their own itches. This is just how free software
works.
And they would probably have to spend nearly as much time checking
my patch as they would writing it themselves anyway.

No: if you already have done the testing, and provided test cases
to test it, this is fairly easy to review.

Regards,
Martin
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Thanks for explaining why the OP was rude. Having been
reading and listening to english for only a few decades
probably, I am sure the OP (and me too!) appreciates your
explanation of rudeness

You mean, you don't feel insulted if somebody calls you
silly?

Regards,
Martin
 
O

OKB (not okblacke)

Russ said:
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 the same could be said of virtually all exceptions. What I
think would be ideal is that whenever an exception is raised, the
traceback tells you:

1) What the exception is
2) The names of the variables involved in the offending expression
(or their character position in the line)
3) The values of those variables

This would be especially useful in cases where you have some long
expression and you get a "cannot concatenate str and list" or whatever.
The irritating thing about this as it is is that you cannot tell which
variables in the expression are causing the problem.

I realize that in some cases the offending expression may not be a
single variable, but I am curious whether it would be possible for
something like this:

"1" + "2" + "3" + "4" + 5 + "6"

To point to the actual addition that raises the exception (somewhat
like it does for a syntax error), instead of just saying "there is an
error somewhere in this line".

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
R

rurpy

Martin said:
You mean, you don't feel insulted if somebody calls you
silly?

This is a hypothetical question, right? Since the OP
didn't call you or anyone else silly.

O.P. said:
Now, that would be rather silly. I would have to familiarize
myself with the code for the Python interpreter,

Seems to me he called the suggestion (made without any
knowlage of the OP's abilities regarding C and Python's
internals) that he summit a patch, silly.

I aggree.

His response was well within the bounds of normal
usenet discourse.
 
?

=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=

Yes, that is true. The information is readily available.

It's not true that it is "trivial" to fix, though: for every fix, there
ought to be a new test case also, and you have to run the test suite.
Depending on how fast a developer is, it may take between 30min and
1hour to get a fix implemented (for the list case alone, not counting
all the other sequences).

Maybe it is not as trivial as the OP thought, but it can't be that
hard. It could be implemented as a utility function that does the
index checking:

bool
PyObject_IsIndexOutOfBounds(PyObject *o, const char *ob_name, int i)
{
if (i < 0 || i >= o->ob_size)
{
char buf[256];
const char fmt[] = "%s index %d not in range(%d)"
snprintf(buf, fmt, ob_name, i, o->ob_size);
PyErr_SetString(PyExc_IndexError, buf);
return true;
}
return false;
}

Then replace all code like:

if (i < 0 || i >= a->ob_size) {
PyErr_SetString(PyExc_IndexError, "string index out of range");
return NULL;
}

with:

if (PyObject_IsOutOfBounds((PyObject *)a, "string", i)
return NULL;

Or maybe add "index" and "length" attributes to the PyExc_IndexError?
"index" and "length" would of course be the invalid index and "length"
the length of the container. That would be harder and probably involve
some API change or something.

Sorry I haven't thought this through 100%, but I don't see how
actually _implementing it_ (getting it through the layers of
bureaucracy may be harder) could be so difficult.
Even though I could fix it, I don't feel tempted to do so: I never had
this problem; in most cases of IndexError, it was very clear what the
problem was so I didn't need the additional information.

For you yes, for a newbie the extra information would certainly be helpful.
 
?

=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=

I think the same could be said of virtually all exceptions. What I
think would be ideal is that whenever an exception is raised, the
traceback tells you:

1) What the exception is
2) The names of the variables involved in the offending expression
(or their character position in the line)
3) The values of those variables

There was a patch to that effect and a thread about it on python-dev
two years ago [1]. Most python-devvers seemed skeptical. But the issue
haven't come to closure yet.

[1] - http://mail.python.org/pipermail/python-dev/2005-February/051470.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top