Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: how to avoid leading white spaces Date: 6 Jun 2011 17:56:45 GMT Organization: Norwich University Lines: 23 Message-ID: <954imtF432U1@mid.individual.net> References: <9e861b0e-e768-401b-b5ca-190f20830a08@s9g2000yqm.googlegroups.com> <94ph22FrhvU5@mid.individual.net> <4de8eef1$0$29996$c3e8da3$5496439d@news.astraweb.com> <1237a287-10b0-4a2d-ba35-97b5238deda1@n11g2000yqf.googlegroups.com> <94svm4Fe7eU1@mid.individual.net> <65164054-f11d-4f8e-a141-31513e70ca04@h9g2000yqk.googlegroups.com> <954cb5F5qbU1@mid.individual.net> <954gd8Fh73U1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net azL/sHOlnNPYHGybREB4YwLUTjQa/UR2yF37jHp1yb0jB9RhBM Cancel-Lock: sha1:nya6F4JqfYg23kvLZMoQfl7JAkA= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7103 On 2011-06-06, Ian Kelly wrote: > Fair enough, although if you ask me the + 1 is just as magical > as the + 7 (it's still the length of the string that you're > searching for). Also, re-finding the opening ' still repeats > information. Heh, true. I doesn't really repeat information, though, as in my version there could be intervening garbage after the TABLE=, which probably isn't desirable. > The main thing I wanted to fix was that the second .index() > call had the possibility of raising an unhandled ValueError. > There are really two things we have to search for in the line, > either of which could be missing, and catching them both with > the same except: clause feels better to me than checking both > of them for -1. I thought an unhandled ValueError was a good idea in that case. I knew that TABLE= may not exist, but I assumed if it did, that the quotes are supposed to be there. -- Neil Cerutti