classification
Title: int() documentation does not specify default radix
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, tcdelaney
Priority: normal Keywords:

Created on 2007-09-24 12:04 by tcdelaney, last changed 2007-09-24 17:59 by georg.brandl. This issue is now closed.

Messages (2)
msg56110 - (view) Author: Tim Delaney (tcdelaney) Date: 2007-09-24 12:04
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.
msg56119 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-24 17:59
The default radix is, and was always AFAICS, 10. I've now documented
that in rev. 58244, 58245.
History
Date User Action Args
2007-09-24 17:59:39georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg56119
2007-09-24 17:47:57georg.brandlsetassignee: georg.brandl
nosy: + georg.brandl
2007-09-24 17:19:53jafosetpriority: normal
2007-09-24 12:04:16tcdelaneycreate