8

Python.. I seriously thought we understood each other but I guess it's all over now.💔

Comments
  • 2
    About to hit repost when it struck me.
  • 8
    I see nothing wrong here
  • 1
    @Kimmax Why is it False in the second case and not in the first
  • 3
  • 1
    @Demolishun Actually explains the same thing, but yours is more comprehensive :)
  • 1
    Identity a != Value 1000
    Identity a = identity implicit(0) = boolean
  • 1
    Algorithm at it aga...wait...
  • 1
    Wait why did you post this twice with a different caption?
  • 1
    @AlgoRythm because both are different
  • 1
    I never even thought about trying to use the "is" operator with numbers. I also will never become a pentester.
  • 2
    In python (and many other languages including java)

    Often used values are pooled. For example numbers up to 256 are pooled in python.

    That means that all numbers up to 256 will have a single place in memory

    a = 256
    a is 256 results in True

    But a = 257
    a is 257 will be False

    The idea is to save time and space for values that appear commonly in code

    This is normal behaviour and also why you should be using == instead of reference comparison (is)
Add Comment