Message56110
The int() documentation (section 2.1) does not specify the default
radix used. Alternatively, it does not specify the default behaviour
for string parsing.
Experimentally, it's parsing with a default radix of 10 - I recall in
an earlier version of Python it parsed with a default radix of zero
(i.e. dependent on the string contents).
I would suggest the following text:
int( [x[, radix]])
Convert a string or number to a plain integer. If the argument is a
string, it must contain a possibly signed decimal number representable
as a Python integer, possibly embedded in whitespace. The radix
parameter gives the base for the conversion and may be any integer in
the range [2, 36], or zero. If radix is zero, the proper radix is
guessed based on the contents of string; the interpretation is the same
as for integer literals. If radix is specified and x is not a string,
TypeError is raised. If radix is not specified, and x is a string, the
interpretation is as if a radix of 10 was specified. Otherwise, the
argument may be a plain or long integer or a floating point number.
Conversion of floating point numbers to integers truncates (towards
zero). If the argument is outside the integer range a long object will
be returned instead. If no arguments are given, returns 0. |
|
Date |
User |
Action |
Args |
2007-09-24 12:04:16 | tcdelaney | set | spambayes_score: 0.153285 -> 0.15328455 recipients:
+ tcdelaney |
2007-09-24 12:04:16 | tcdelaney | set | spambayes_score: 0.153285 -> 0.153285 messageid: <1190635456.12.0.478143217592.issue1196@psf.upfronthosting.co.za> |
2007-09-24 12:04:16 | tcdelaney | link | issue1196 messages |
2007-09-24 12:04:15 | tcdelaney | create | |
|