SIP is working great for me so far, enough so that I'm coming to the question
of what to do with keyword arguments. I've got a fairly large code base, part
of which makes calls to GUI control constructors using keyword arguments.

It's actually a fairly limited subset of methods, so my initial thought was
just to patch in kwarg-accepting methods in before using them, and solve the
harder problem of giving keyword-argument support to SIP later.

My approach was this:

old_init = MyClass.__init__ def new_init(self, foo, bar=5, meep=13):
old_init(self, foo, bar, meep) MyClass.__init__ = new_init

assert MyClass.__init__ is new_init # FAIL

But that last assert fails. The new_init method seems to go /somewhere/, though
because the error I get changes from "function doesn't support keyword
arguments" to something weird and vague like "TypeError: an integer is
required".

In another thread about lazy method lookups
(http://article.gmane.org/gmane.comp.python.pyqt-pykde/4157/match=lazy) the
sentence "The normal getattro method is used first (in case the user as
manually patched in a method)" seems to imply what I'm doing should work.

Any ideas on why that assert fails, and what I can do about it?



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to