aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/scripts
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-01-19 04:58:36 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-01-19 04:58:36 +0000
commit6138980e885884ef96b726f695fb038e2b939935 (patch)
tree764c56a9a16e4175699ba9fd5cb45a9a3282fe46 /externals/grill/py/scripts
parent86ecf983a799e73b54a13616e5fda6b268c20e5e (diff)
- 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
Diffstat (limited to 'externals/grill/py/scripts')
-rw-r--r--externals/grill/py/scripts/pak.py6
-rw-r--r--externals/grill/py/scripts/script.py5
-rw-r--r--externals/grill/py/scripts/sendrecv.py8
-rw-r--r--externals/grill/py/scripts/simple.py20
4 files changed, 20 insertions, 19 deletions
diff --git a/externals/grill/py/scripts/pak.py b/externals/grill/py/scripts/pak.py
index 17841630..6394570d 100644
--- a/externals/grill/py/scripts/pak.py
+++ b/externals/grill/py/scripts/pak.py
@@ -8,7 +8,7 @@ class pak(pyext._class):
# initialize list
self.lst = [0 for x in range(n)]
- def _anything_(self,n,args):
- # args should be type-checked!
- self.lst[n-1] = args
+ def _anything_(self,n,arg):
+ # arg should be type-checked!
+ self.lst[n-1] = arg
self._outlet(1,self.lst)
diff --git a/externals/grill/py/scripts/script.py b/externals/grill/py/scripts/script.py
index b4741b00..88f7afd2 100644
--- a/externals/grill/py/scripts/script.py
+++ b/externals/grill/py/scripts/script.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.
#
@@ -22,7 +22,8 @@ def numargs(*args): # variable argument list
def strlen(arg):
"""Return the string length"""
- return len(arg)
+ # we must convert to string first (it's a symbol type most likely)
+ return len(str(arg))
def strcat(*args):
diff --git a/externals/grill/py/scripts/sendrecv.py b/externals/grill/py/scripts/sendrecv.py
index e3295ab6..a8b57469 100644
--- a/externals/grill/py/scripts/sendrecv.py
+++ b/externals/grill/py/scripts/sendrecv.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.
#
@@ -49,7 +49,7 @@ class ex1(pyext._class):
recvname=""
sendname=""
- def recv(self,arg):
+ def recv(self,*arg):
"""This is a class-local receive function, which has access to class members."""
# print some stuff
@@ -59,7 +59,7 @@ class ex1(pyext._class):
self._send(self.sendname,arg)
- def __init__(self,args):
+ def __init__(self,*args):
"""Class constructor"""
# store sender/receiver names
@@ -100,7 +100,7 @@ class ex2(pyext._class):
recvname=""
- def recv(self,arg):
+ def recv(self,*arg):
"""This is a class-local receive function"""
# send received data to outlet
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