How to get a unique id for bound methods?

Russell E. Owen rowen at cesmail.net
Tue Aug 23 22:02:21 CEST 2005


In article <mailman.3378.1124742573.10512.python-list at python.org>,
 "Fredrik Lundh" <fredrik at pythonware.com> 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 create a name for tk that is unique to my python
>>>>"function". A hash-like name would be perfect, meaning a name that is
>>>>always the same for a particular python "function" and always different
>>>>for a different python "function". That would save a lot of housekeeping.
>
>have you tried Tkinter's built-in _register method?
>
>>>> import Tkinter
>>>> w = Tkinter.Tk()
>>>> help(w._register)
>Help on method _register in module Tkinter:
>
>_register(self, func, subst=None, needcleanup=1) method of Tkinter.Tk 
>instance
>    Return a newly created Tcl function. If this
>    function is called, the Python function FUNC will
>    be executed. An optional function SUBST can
>    be given which will be executed before FUNC.

Thanks. That looks like just the thing. I think I had seen it but was 
deterred by the leading underscore (suggesting an internal method whose 
interface might change). Still, I guess if it gets modified I can just 
change my code.

-- Russell



More information about the Python-list mailing list