newbie question int to string conversion
D'Arcy J.M. Cain
darcy at vex.net
Sat Oct 2 06:36:40 EDT 1999
Anders olme <olme at ebox.tninet.se> wrote:
> I'm tryinig to convert a list of strings to integer.
> The problem is that not all elements are numbers some of them contains letters
> Is there any easy way to determine is a strings contains illegal charaters?
> Now I only get exceptions and I think a exceptionshandler is a bit overkill
> for my needs.
Does exception handling carry a lot of overhead? I routinly do things
like this.
try: return string.atoi(v)
except:
try: return string.atof(v)
except: return string.strip(v)
Of course, this is in a CGI where network lag hides a multitude of sins. :-)
--
D'Arcy J.M. Cain <darcy at caingang.com> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
More information about the Python-list
mailing list