On Apr 8, 2:15 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: (snip) > 2. Replace text with: > Convert a number or string to an integer. If no arguments are given, > return 0. If a number is given, return number.__int__(). Conversion of > floating point numbers to integers truncates towards zero. A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test.
One thing though, I think it should say "may be surrounded by whitespace" as opposed to "optionally surrounded by whitespace". On Apr 7, 1:55 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-04-06, Lie <[EMAIL PROTECTED]> wrote: > > > I've noticed some oddly inconsistent behavior with int and float: > > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > >>>> int('- 345') > > -345 > > > works, > > IMO, it oughtn't. > > >>>> float('- 345.083') > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > ValueError: invalid literal for float(): - 345.083 > > That's the behavior I'd expect. Sorry to confuse you, by works I mean that the interpreter doesn't complain at all, I didn't mean that it works as it should be. -- http://mail.python.org/mailman/listinfo/python-list