[Python-ideas] int('0x3241fca1')
MRAB
python at mrabarnett.plus.com
Thu Feb 6 23:04:13 CET 2014
On 2014-02-06 21:41, Terry Reedy wrote:
> On 2/6/2014 5:24 AM, Ram Rachum wrote:
>> What do you think about letting the `int` constructor automatically
>> understand the number type without specifying base if given a prefix, so
>> int('0x3414fa') would immediately work without specifying a base of 16?
>
> In addition to int(string, 0):
>
> >>> number = '0x3414fa'
> >>> eval(number)
> 3413242
>
The disadvantage is that it'll evaluate (run) anything, so it's unsafe
in the general case.
More information about the Python-ideas
mailing list