is id(self) constant over an object lifetime ?

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Dec 3 08:53:38 EST 2010


Jean-Michel Pichavant wrote:
> Hello fellows,
>
> I would need a unique internal identifier to an object. Can I use the 
> object python id ?
>
> class Foo:
> def getUniqueIdentifier():
> return id(self)
>
>
> This id needs to be unique and constant over the python process lifetime.
>
> JM
>
sorry guys

"

id(/object/)¶ <http://docs.python.org/library/functions.html#id>

    Return the “identity” of an object. This is an integer (or long
    integer) which is guaranteed to be unique and constant for this
    object during its lifetime. Two objects with non-overlapping
    lifetimes may have the same id()
    <http://docs.python.org/library/functions.html#id> value.

"


Next time I promise to look at the doc before actually asking the 
question here :)

JM



More information about the Python-list mailing list