Python id() FunctionPython Functions

Difficulty Level:
Difficulty Level:

The id() function is used to get the address of an object in memory.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

a=1
print("the memory address of a is ", id(a))

b=12
print("the memory address of a is ", id(b))

c=101
print("the memory address of a is ", id(c))

Output:

the memory address of a is  1574749872
the memory address of a is  1574750224
the memory address of a is  1574753072

Syntax

id([object])

Parameters

Name Description
object The object name.

Return Value

It returns the memory address of an object.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us