0
>>> x = "hello world"
>>> x
'hello world'
>>> id(x)
140461077304368

We get the address 140461077304368 which contains hello world.

>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'x']

The variable name x is in the namespace,what is the x 's address ?There is a also container which contain x,what is the address for container ?
dir() will ocupy memory space,x locate in the space,what is the address for the space? what is the address for items such as __spec__ then?

showkey
  • 479
  • 37
  • 122
  • 257
  • 1
    https://stackoverflow.com/questions/121396/accessing-object-memory-address says: `id()` gives location of `x` in memory, if you want the address in 'standard' hex format, you can convert the integer from `id()` like `hex(id(x))`. For the container part, I am not sure what you are asking but same goes for `dir()`, you can do `hex(id(dir()))` – Bijay Regmi Oct 30 '21 at 12:11

0 Answers0