__dict__ for instances?

Ivan Voras ivoras at __fer.hr__
Sat May 12 20:20:15 EDT 2007


While using PyGTK, I want to try and define signal handlers
automagically, without explicitly writing the long dictionary (i.e. I
want to use signal_autoconnect()).

To do this, I need something that will inspect the current "self" and
return a dictionary that looks like:

{
  "method_name" : self.method_name
}

Class.__dict__ does something very similar, but when I use it, either
I'm doing something wrong or it doesn't return methods bound to "self",
and python complains a wrong number of arguments is being passed to the
methods (one instead of two).

instance.__dict__ on the other hand returns an empty dictionary.

This looks like it should be easy, but I can't find the solution :(

-- 
(\__/)
(O.o)
(> < )

This is Bunny.
Copy Bunny into your signature to help him on his way to world domination!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20070513/1615690f/attachment.sig>


More information about the Python-list mailing list