Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18024
| Date | 2011-12-27 07:54 -0800 |
|---|---|
| From | Charles Hixson <charleshixsn@earthlink.net> |
| Subject | Re: Possible bug in string handling (with kludgy work-around) |
| References | <4EF8F3C7.3010005@earthlink.net> <CAPTjJmpHwysHRNNo2P87mvB3i_7ejOwRtv2=Jds2YKss30s93g@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4134.1325001725.27778.python-list@python.org> (permalink) |
That was it! Thanks. On 12/26/2011 02:44 PM, Chris Angelico wrote: > 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 > Sorry I didn't specify things more clearly. -- Charles Hixson
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Possible bug in string handling (with kludgy work-around) Charles Hixson <charleshixsn@earthlink.net> - 2011-12-27 07:54 -0800
csiph-web