integer's methods

BartC bc at freeuk.com
Thu Aug 18 09:13:54 EDT 2016


On 18/08/2016 14:01, Marko Rauhamaa wrote:
> "ast" <nomail at com.invalid>:
>
>>>>> 123.bit_length()
>> SyntaxError: invalid syntax
>
> I fell into that trap myself.
>
> CPython's lexical analyzer can't handle a dot after an integer literal
> so you must add a space in between "123" and ".".

Or use (123).bit_length() which looks slightly less odd.

-- 
bartc



More information about the Python-list mailing list