integer's methods
Steve D'Aprano
steve+python at pearwood.info
Fri Aug 19 02:47:56 EDT 2016
On Thu, 18 Aug 2016 10:58 pm, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
>
>>>> 123.bit_length()
> SyntaxError: invalid syntax
Because Python thinks you are writing a float, and "b" is not a valid digit.
Try:
(123).bit_length()
123 .bit_length()
instead.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list