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


Groups > comp.lang.python > #18024

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <charleshixsn@earthlink.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python,': 0.01; 'subject:bug': 0.04; 'indexes': 0.09; 'message-id:@earthlink.net': 0.09; 'referencing': 0.09; 'subject:string': 0.09; 'am,': 0.12; '"from': 0.16; 'helps!': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'subject:handling': 0.16; 'wrote:': 0.18; 'dec': 0.22; '(or': 0.22; "doesn't": 0.22; 'header :In-Reply-To:1': 0.22; 'incorrect': 0.23; 'indexing': 0.23; 'specify': 0.24; 'code': 0.25; 'thanks.': 0.26; 'expect': 0.26; 'code,': 0.27; 'asking': 0.28; 'bit': 0.28; '27,': 0.29; 'from:addr:earthlink.net': 0.29; 'pm,': 0.29; 'character.': 0.30; 'chris': 0.30; "i've": 0.31; "didn't": 0.31; 'tue,': 0.32; 'header :User-Agent:1': 0.33; 'actually': 0.33; 'rather': 0.33; 'to:addr :python-list': 0.34; 'character': 0.34; 'things': 0.34; 'see,': 0.34; 'subject:work': 0.34; 'subject:with': 0.36; 'themselves.': 0.37; 'but': 0.37; 'using': 0.38; 'subject: (': 0.40; 'to:addr:python.org': 0.40; 'hope': 0.61; 'more': 0.61; '2011': 0.61; 'your': 0.61; 'cause': 0.67; 'charles': 0.67; 'marker': 0.84; 'received:207.69': 0.84; 'received:207.69.195': 0.84; 'subject:Possible': 0.84; 'examining': 0.91
Date Tue, 27 Dec 2011 07:54:57 -0800
From Charles Hixson <charleshixsn@earthlink.net>
User-Agent Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: Possible bug in string handling (with kludgy work-around)
References <4EF8F3C7.3010005@earthlink.net> <CAPTjJmpHwysHRNNo2P87mvB3i_7ejOwRtv2=Jds2YKss30s93g@mail.gmail.com>
In-Reply-To <CAPTjJmpHwysHRNNo2P87mvB3i_7ejOwRtv2=Jds2YKss30s93g@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4134.1325001725.27778.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325001725 news.xs4all.nl 6875 [2001:888:2000:d::a6]:46116
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18024

Show key headers only | View raw


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


Thread

Re: Possible bug in string handling (with kludgy work-around) Charles Hixson <charleshixsn@earthlink.net> - 2011-12-27 07:54 -0800

csiph-web