class a(object):
    pass

b = a()
print id(b)
20441744

Is it possible to get the instance from this number/address?

I don't think there's a built-in way to do this. Of course you can roll your own with a dictionary, viz:

class a(object):
	IDmap = {}
	def __init__(self):
		a.IDmap[id(self)] = self

b = a()
print id(b)           #  13975472
print a.IDmap[id(b)]  #  <__main__.a object at 0x00D53FB0>

Of course, 0x00D53FB0 == 13975472

Isn't the number just an arbitrary pointer to a place in the memory that has been allocated for the given instance?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.