22

Since everything is an object in python, even literals, we are typically allowed to call methods directly on a literal.

ex:

'hello'.upper()

In theory, it seems like the same thing should be allowed for int literals

ex:

4.bit_length()

However, this doesn't work, and I'm not sure why. Any ideas? Thanks!

Levon
  • 138,105
  • 33
  • 200
  • 191
CADBOT
  • 416
  • 2
  • 9

0 Answers0