Who knows somefunction?

Tim Peters tim.one at comcast.net
Thu Sep 26 19:08:10 EDT 2002


[Gregor Lingl]
> Is there a function <somefunction> in Python for which
>
> something is <somefunction>(id(something))
>
> returns invariably true?

[Tim]
> I'm not sure you're asking the question you intended to ask, but str()
> is one answer to the question you actually asked.

[Gregor]
> I don't think so:
>  >>> something = [1,2,3]
>  >>> something is str(id(something))
> 0
>
> How did you understand my question?
> (Errors should never pass silently)

Seemingly in a way other than you asked it <wink>.

Marc-Andre Lemburg's mxTools extension adds such a function to the sys
module (sys.makeref(id)).  It's impossible for him to do this safely, so
believe his warnings when you read them.

conjuring-things-into-existence-by-naming-them-is-a-trick-
    best-left-to-gods-ly y'rs  - tim





More information about the Python-list mailing list