Python Forum
Python's id() function output in prompt and script mode
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python's id() function output in prompt and script mode
#1
In CPython it is agreed that id's (in effect addresses) of objects with values > 256 should be different.

When using the Python prompt in a terminal this is exactly what happens. Doing the same by running a script with the same Python contents gives identical id's.

Python 3 Prompt
>>> a = 500
>>> b = 500
>>> print(id(a))
139745079475056
>>> print(id(b))
139745079475248
Script test.py
python3 /tmp/test.py
139835321420368
139835321420368

Can anyone shine some light on this please?
Reply


Messages In This Thread
Python's id() function output in prompt and script mode - by stormshadow - Dec-06-2018, 12:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in output of a function akbarza 9 1,212 Sep-29-2023, 11:13 AM
Last Post: snippsat
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,280 Jun-29-2023, 11:57 AM
Last Post: gologica
  How to print the output of a defined function bshoushtarian 4 1,321 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  Open windows cmd prompt and run cmds with python Extra 3 1,457 Jul-14-2022, 06:07 AM
Last Post: Gribouillis
  Real-Time output of server script on a client script. throwaway34 2 2,061 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  output correction using print() function afefDXCTN 3 11,110 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx
  things that work in terminal mode but not in sublime mode alok 4 2,897 Aug-11-2021, 07:02 PM
Last Post: snippsat
  string function doesn't work in script ClockPillow 3 2,423 Jul-13-2021, 02:47 PM
Last Post: deanhystad
  python prints none in function output chairmanme0wme0w 3 2,232 Jul-07-2021, 05:18 PM
Last Post: deanhystad
  Automatic user/password entry on prompt by bash script PBOX_XS4_2001 3 2,793 May-18-2021, 06:42 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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