I launch the same program in Visual Studio or Anaconda:
a = 777 b = 777 print('a is b ? ', a is b) #должно быть False print('a == b ? ', a == b) print( 'id(a)' ,id(a)) print( 'id(b)' ,id(b)) I get True True and the same id. The result of the work does not match the description of the Python language in the standard. Then I type the same code in the console and get the correct result:
False True and different id.
What is the secret of a buried dog?
777constant caching did not occur because of what a new was created on each assignment object with reference to777. And when you started the.pyfile, the interpreter optimized the code by doing that caching - gil9reda=777;b=777in one line - and you also get True. Nobody forbids the interpreter to combine the same numbers into one object - andreymal