On Sun, Feb 09, 2003 at 10:55:11PM +0100, Martijn Brouwer wrote:
> I do not understand the meaning of *args. It looks like a c pointer
> ;-) I guess it is something else, but I could not find anything in the
> python docs.
Woot! Time to find a new set of docs, then :)
> def on_key_press(widget, event, *args):
Here are some local copies of Python documentation pages that describe
this syntax:
http://doc.async.com.br/python/2.1.3/ref/function.html
http://doc.async.com.br/python/2.1.3/ref/calls.html#calls
Basically, all arguments passed in after the second will be stored in a
tuple called args. A `print args' will make it clear. I use this pattern
often because I don't remember what signatures signals expect and there
is no good reference documentation on it - using *args just lets me stop
worrying about it.
Also, it allows the function to be used as a callback to multiple
signals which have different signatures.
Mind you I've been highly criticized for [ab]using this pattern in
callback functions before. I'll come clean: I don't care 8)
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/