Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Interpreter and running a .py file give different outputs
I have written the following code which gives different output when saved as a .py file and run and on the Python interpreter.

print (id(a),id(b),id(c))
Output when saving as .py file and running through command prompt:
2122603390032 2122603390032 2122603390032

All memory addresses are same.

Output via interpreter:
2351093736464 2351093736464 2351093736304

Last memory address is different.

Why is this happening? I am on Python 3.7.4.
What are the differences when running on the interpreter and when running a .py file.
buran wrote Jul-14-2019, 06:57 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Memory locations are not ever guaranteed to be in the same location. It' assigned at time or operation.
(Jul-14-2019, 10:14 AM)Larz60+ Wrote: Memory locations are not ever guaranteed to be in the same location. It' assigned at time or operation.

Yes, I am aware of that.

But every time I run the .py file, the memory locations are the same, while every time I run the same code via the interpreter the memory locations are different.

So is it that the interpreter runs programs slightly differently as compared to running a .py file directly?

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Virtualenv and an infinitely spooling interpreter? eblade 3 157 Jul-11-2019, 06:58 PM
Last Post: eblade
  How to create an 'interpreter of assembler' Jaccobtw 2 80 Jul-11-2019, 01:38 AM
Last Post: ichabod801
  Where is usually located the python interpreter on android devices? anddontyoucomebacknomore 1 124 Jul-03-2019, 06:32 PM
Last Post: metulburr
  error running script in python3.7.2 interpreter srm 4 198 May-23-2019, 01:09 PM
Last Post: snippsat
  Batch file not running python script in task scheduler davork 3 229 May-09-2019, 12:53 PM
Last Post: Gribouillis
  Running python file without python mzmingle 2 250 Apr-18-2019, 08:43 PM
Last Post: snippsat
  CPython: Knowing when the interpreter expects more input b0bh00d 1 138 Apr-18-2019, 05:08 PM
Last Post: Gribouillis
  Multiple calls to Python interpreter embedded in C++ application yield segmentation f mmoelle1 0 171 Mar-21-2019, 08:54 PM
Last Post: mmoelle1
  How to recognize, what functions are filled in of the Python interpreter stack? AlekseyPython 3 190 Mar-13-2019, 12:14 PM
Last Post: AlekseyPython
  vs code interpreter vs IDLE feature tsmspace 3 305 Mar-02-2019, 05:25 PM
Last Post: perfringo

Forum Jump:

Users browsing this thread: 1 Guest(s)