[IronPython] System.Convert Problem

Ernst, Nathan Nathan.Ernst at citadelgroup.com
Fri Mar 10 22:19:27 CET 2006

If you're trying to convert strings to ints in IronPython, the pythonic
way of doing it would be to use the built-in "int":

>>> int("A")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): A
>>> int("A", 16)

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Davy Mitchell
Sent: Friday, March 10, 2006 3:10 PM
To: Discussion of IronPython
Subject: Re: [IronPython] System.Convert Problem

On 3/10/06, Ernst, Nathan <Nathan.Ernst at citadelgroup.com> wrote:
> This makes perfect sense.  "A" cannot be converted to an integer -
> unless you specify a base, e.g. 16 to treat this as a hex digit.

Thanks for the quick response Nathan. It now makes sense to me too :-)

BTW I switched from System.Convert to the VB Strings Class which made
things much easier as this is a port from VB.NET :-)

Davy Mitchell

Mood News
 - BBC News Headlines Auto-Classified as   Good,   Bad or   Neutral.
users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list