[New-bugs-announce] [issue1196] int() documentation does not specify default radix

Tim Delaney report at bugs.python.org
Mon Sep 24 14:04:16 CEST 2007


New submission from Tim Delaney:

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.

----------
components: Documentation
messages: 56110
nosy: tcdelaney
severity: normal
status: open
title: int() documentation does not specify default radix
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1196>
__________________________________


More information about the New-bugs-announce mailing list