integer's methods
Grant Edwards
grant.b.edwards at gmail.com
Sat Aug 27 13:24:48 EDT 2016
On 2016-08-18, ast <nomail at com.invalid> wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
>
>>>> 123.bit_length()
> SyntaxError: invalid syntax
Becuase the parser thinks you've entered a floating point number with
a fractional part of "bit_length".
You need to enter the integer such that it's identified by the parser
as an integer rather than as a broken floating point number:
>>> (123).bit_length()
7
>>> 123 .bit_length()
7
--
Grant Edwards grant.b.edwards Yow! Look DEEP into the
at OPENINGS!! Do you see any
gmail.com ELVES or EDSELS ... or a
HIGHBALL?? ...
More information about the Python-list
mailing list