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

a=100000
b=a
c=100000
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.
Reply


Messages In This Thread
Interpreter and running a .py file give different outputs - by PythonNPC - Jul-14-2019, 05:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error "cannot identify image file" part way through running hatflyer 0 656 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  format json outputs ! evilcode1 3 1,733 Oct-29-2023, 01:30 PM
Last Post: omemoe277
  Formatting outputs created with .join command klairel 2 614 Aug-23-2023, 08:52 AM
Last Post: perfringo
  Web project and running a .py file emont 0 634 Dec-11-2022, 11:15 PM
Last Post: emont
  I have written a program that outputs data based on GPS signal kalle 1 1,161 Jul-22-2022, 12:10 AM
Last Post: mcmxl22
  batch file for running python scipt in Windows shell MaartenRo 2 1,880 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  Why does absence of print command outputs quotes in function? Mark17 2 1,371 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  Thoughts on interfacing with a QR code reader that outputs keystrokes? wrybread 1 1,465 Oct-08-2021, 03:44 PM
Last Post: bowlofred
  PyCharm One Interpreter for every file? muzikman 3 1,856 Sep-28-2021, 02:09 AM
Last Post: snippsat
  Combining outputs into a dataframe rybina 0 1,667 Mar-15-2021, 02:43 PM
Last Post: rybina

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020