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


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

Re: using split for a string : error

Started by"Tobias M." <tm@tobix.eu>
First post2013-01-24 12:16 +0100
Last post2013-01-24 12:16 +0100
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: using split for a string : error "Tobias M." <tm@tobix.eu> - 2013-01-24 12:16 +0100

#37563 — Re: using split for a string : error

From"Tobias M." <tm@tobix.eu>
Date2013-01-24 12:16 +0100
SubjectRe: using split for a string : error
Message-ID<mailman.962.1359026211.2939.python-list@python.org>
Chris Angelico wrote:
>
>
> The other thing you may want to consider, if the values are supposed
> to be integers, is to convert them to Python integers before
> comparing. Currently, you're working with strings. Replace this:
>
> if sp[9] == sp[10]:
>
> with this:
>
> if int(sp[9]) == int(sp[10]):
I thought of this too and I wonder if there are any major differences 
regarding performance compared to using the strip() method when parsing 
large files.

In addition I guess one should catch the ValueError that might be raised 
by the cast if there is something else than a number in the file.

[toc] | [standalone]


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


csiph-web