Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17988 > unrolled thread

Re: Possible bug in string handling (with kludgy work-around)

Started byChris Angelico <rosuav@gmail.com>
First post2011-12-27 09:44 +1100
Last post2011-12-27 09:44 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Possible bug in string handling (with kludgy work-around) Chris Angelico <rosuav@gmail.com> - 2011-12-27 09:44 +1100

#17988 — Re: Possible bug in string handling (with kludgy work-around)

FromChris Angelico <rosuav@gmail.com>
Date2011-12-27 09:44 +1100
SubjectRe: Possible bug in string handling (with kludgy work-around)
Message-ID<mailman.4114.1324939502.27778.python-list@python.org>
On Tue, Dec 27, 2011 at 9:23 AM, Charles Hixson
<charleshixsn@earthlink.net> wrote:
> This doesn't cause a crash, but rather incorrect results.

You may need to be a bit clearer. What line of code (or what
expression)? What did you expect to see, and what did you see?

>From examining your code, I've come up with one most-likely scenario.
In Python, indexing is zero-based and, in effect, indexes the
boundaries between items rather than the items themselves. Referencing
string[-1] actually means asking for the boundary between the
second-last and last characters; using that as your end marker
actually trims off the last character. What you may want is simply:

self.wordList[i][1:]

which means "from character position 1 to the end of the string".

Hope that helps!

Chris Angelico

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web