This is a parser.
When Python sees . , he begins to look for decimal numbers. Your decimal is b , so it fails.
If you execute (5).bit_length() , then Python will first analyze what is between () , and then look for the bit_length method.
If you try:
5..zzz
You will get the AttributeError that you expect. This will not work for integers: 5. is a float.
source share