From 6138980e885884ef96b726f695fb038e2b939935 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 19 Jan 2005 04:58:36 +0000 Subject: - a bit more functions for the symbol type - exporting symbol functions corrected argument passing to class methods updated for OSX adjust pd and py files for correct argument passing svn path=/trunk/; revision=2523 --- externals/grill/py/scripts/simple.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'externals/grill/py/scripts/simple.py') diff --git a/externals/grill/py/scripts/simple.py b/externals/grill/py/scripts/simple.py index b178bf35..04bea7ac 100644 --- a/externals/grill/py/scripts/simple.py +++ b/externals/grill/py/scripts/simple.py @@ -1,6 +1,6 @@ # py/pyext - python script objects for PD and MaxMSP # -# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +# Copyright (c) 2002-2005 Thomas Grill (gr@grrrr.org) # For information on usage and redistribution, and for a DISCLAIMER OF ALL # WARRANTIES, see the file, "license.txt," in this distribution. # @@ -24,14 +24,14 @@ pyext Usage: e.g. if your PD or MaxMSP object looks like [pyext script class arg1 arg2 arg3] - then the __init__(self,args) function will be called with a tuple argument + then the __init__(self,*args) function will be called with a tuple argument args = (arg1,arg2,arg3) With this syntax, you will have to give at least one argument. By defining the constructor as __init__(self,*args) you can also initialize the class without arguments. - Methods called by pyext - The general format is 'tag_inlet(self,args)' resp. 'tag_inlet(self,*args)': + The general format is 'tag_inlet(self,arg)' resp. 'tag_inlet(self,*args)': tag is the PD or MaxMSP message header.. either bang, float, list etc. inlet is the inlet (starting from 1) from which messages are received. args is a tuple which corresponds to the content of the message. args can be omitted. @@ -40,9 +40,9 @@ pyext Usage: Here, the inlet index is a additional parameter to the method You can also set up methods which react on any message. These have the special forms - _anything_inlet(self,args) + _anything_inlet(self,*args) or - _anything_(self,inlet,args) + _anything_(self,inlet,*args) Please see below for examples. @@ -89,7 +89,7 @@ class ex1(pyext._class): def float_1(self,f): print "Float",f,"into first inlet" - def list_1(self,s): + def list_1(self,*s): print "List",s,"into first inlet" @@ -107,7 +107,7 @@ class ex1(pyext._class): def go_2(self): print "Tag 'go' into second inlet" - def _anything_2(self,args): + def _anything_2(self,*args): print "Some other message into second inlet:",args @@ -116,13 +116,13 @@ class ex1(pyext._class): def onearg_3(self,a): print "Tag 'onearg' into third inlet:",a - def twoargs_3(self,a): + def twoargs_3(self,*a): if len(a) == 2: print "Tag 'twoargs' into third inlet:",a[0],a[1] else: print "Tag 'twoargs': wrong number of arguments" - def threeargs_3(self,a): + def threeargs_3(self,*a): if len(a) == 3: print "Tag 'threeargs' into third inlet",a[0],a[1],a[2] else: @@ -149,7 +149,7 @@ class ex2(pyext._class): def hello_(self,n): print "Tag 'hello' into inlet",n - def _anything_(self,n,args): + def _anything_(self,n,*args): print "Message into inlet",n,":",args -- cgit v1.2.1