How to get a unique id for bound methods?

2005-08-19 Thread Russell E. Owen
I have several situations in my code where I want a unique identifier for a method of some object (I think this is called a bound method). I want this id to be both unique to that method and also stable (so I can regenerate it later if necessary). I thought the id function was the obvious choic

Re: How to get a unique id for bound methods?

2005-08-19 Thread Benji York
Russell E. Owen wrote: > The id of two different methods of the same object seems to be the > same, and it may not be stable either. Two facts you're (apparently) unaware of are conspiring against you: 1) the "id" of an object is consistent for the lifetime of the object, but may be reused afte

Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 13:29:19 -0700, "Russell E. Owen" <[EMAIL PROTECTED]> wrote: >I have several situations in my code where I want a unique identifier >for a method of some object (I think this is called a bound method). I >want this id to be both unique to that method and also stable (so I can

Re: How to get a unique id for bound methods?

2005-08-19 Thread Paolino
Russell E. Owen wrote: > The "hash" function looks promising -- it prints out consistent values > if I use it instead of "id" in the code above. Is it stable and unique? > The documentation talks about "objects" again, which given the behavior > of id makes me pretty nervous. > I dont know how

Re: How to get a unique id for bound methods?

2005-08-19 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, Benji York <[EMAIL PROTECTED]> wrote: >Russell E. Owen wrote: >> The id of two different methods of the same object seems to be the >> same, and it may not be stable either. > >Two facts you're (apparently) unaware of are conspiring against you: > >1) the "id" of

Re: How to get a unique id for bound methods?

2005-08-19 Thread Bengt Richter
On Fri, 19 Aug 2005 16:33:22 -0700, "Russell E. Owen" <[EMAIL PROTECTED]> wrote: [...] > >The current issue is associated with Tkinter. I'm trying to create a tk >callback function that calls a python "function" (any python callable >entity). > >To do that, I have to create a name for tk that is

Re: How to get a unique id for bound methods?

2005-08-22 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) wrote: >On Fri, 19 Aug 2005 16:33:22 -0700, "Russell E. Owen" <[EMAIL PROTECTED]> >wrote: >[...] >> >>The current issue is associated with Tkinter. I'm trying to create a tk >>callback function that calls a python "function" (any

Re: How to get a unique id for bound methods?

2005-08-22 Thread Fredrik Lundh
Russell E. Owen wrote: >>>The current issue is associated with Tkinter. I'm trying to create a tk >>>callback function that calls a python "function" (any python callable >>>entity). >>> >>>To do that, I have to create a name for tk that is unique to my python >>>"function". A hash-like name would

Re: How to get a unique id for bound methods?

2005-08-22 Thread Oren Tirosh
Russell E. Owen wrote: > I have several situations in my code where I want a unique identifier > for a method of some object (I think this is called a bound method). I > want this id to be both unique to that method and also stable (so I can > regenerate it later if necessary). >>> def persistent_

Re: How to get a unique id for bound methods?

2005-08-23 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Russell E. Owen wrote: > The current issue is associated with Tkinter. I'm trying to create a tk callback function that calls a python "function" (any python callable entity). To do that, I have to cr

Re: How to get a unique id for bound methods?

2005-08-23 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Russell E. Owen wrote: > The current issue is associated with Tkinter. I'm trying to create a tk callback function that calls a python "function" (any python callable entity). To do that, I have to cr

Re: How to get a unique id for bound methods?

2005-08-23 Thread Fredrik Lundh
Russell E. Owen wrote: > Having looked at it again, it is familiar. I copied it when I wrote my > own code. I avoided using at the time both because the initial > underscore suggested it was a private method and because it introduces > an extra function call. > > _register has the same weakness th

Re: How to get a unique id for bound methods?

2005-08-24 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Russell E. Owen wrote: > >> Having looked at it again, it is familiar. I copied it when I wrote my >> own code. I avoided using at the time both because the initial >> underscore suggested it was a private method and beca