[C++-sig] Re: invalid literal for int()
David Abrahams
dave at boost-consulting.com
Tue Mar 9 14:10:26 CET 2004
"Paul Grenyer" <paul at paulgrenyer.co.uk> writes:
> Hi
>
> The plot has just thickened. The following doesn't produce any errors:
>
> import string
>
> houseno = ADD1[0:2]
>
> if TITLE == "MR":
> if int(houseno) > 0 and int(houseno) < 16:
> outputFile = "Mr.out"
> else:
> outputFile = "rest.out"
>
> However, if I remove the first if statement:
>
> import string
>
> houseno = ADD1[0:2]
>
> if int(houseno) > 0 and int(houseno) < 16:
> outputFile = "Mr.out"
> else:
> outputFile = "rest.out"
>
> I am back to the "invalid literal for int()" error.
>
> I must be doing something very wrong somewhere.
These are pure Python errors, having nothing to do with C++:
>>> int('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): foo
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list