[PyKDE] A simple PyQt program
Gordon Tyler
gordon at doxxx.net
Sun Jun 27 06:15:00 BST 2004
Joshua wrote:
> TypeError: update() takes exactly 2 arguments (3 given)
>
> I don't understand this, since I only gave update 2 arguments. If anyone
> could shed some light on this, I'd greatly appreciate it. Here's the code:
This is something fairly fundamental to Python programming, so you have
to make sure that you understand how this works.
When you have a class with a method:
class Foo:
def bar(self, x):
print x
And you call that method on an instance of the class:
f = Foo()
f.bar("abc")
The instance, f, is automatically passed as the first argument to the
function before any other arguments that are provided in the call.
Therefore, when you declare methods in a class they must have a "self"
parameter as the first parameter.
There's more to this than I've explained here so you should read a
Python book or online manual.
Ciao,
Gordon
More information about the PyQt
mailing list