Hi David,
I'm having a bit of trouble trying to load any other scripts as modules other than scr1.py and scr2.py (the examples)...I have tried loading something simple like:
import sys
def printList(alist, blist=[]): if not len(alist): print ''.join(blist) for i in range(len(alist)): blist.append(alist.pop(i)) printList(alist, blist) alist.insert(i, blist.pop())
if __name__ == '__main__': k='love' if len(sys.argv)>1: k = sys.argv[1] printList(list(k))
PY says it managed to load this little script (which does simple permutation) succesfully, but when given a number as a message or from a number box, it fails with:
py - no method for type float
If the left inlet of py is for calling functions, and the right inlet is for passing stuff to python, shouldn't I be able to give the script above a number like 512 and get permutation back from py? I tried:
message box with 512 | | py permute | | print box
working with py, you will also have to define the function of the Python script to be called, for example
[py permute printList]
you can then try to send it numbers or symbols through the right inlet.
However, your Python script has some caveats. printList always expects a list as its argument but the py external passes floats as numbers and symbols as strings. Therefore, you could define another function
def printAll(v): printList(list(str(v)))
and then (with [py permute printAll]), try to send it numbers or symbols.
Also, your script function doesn't return any values to be printed by the pd print objects but it will rather output the permuted values to the console.
all the best, Thomas
On Tue, 23 Jul 2002, Thomas Grill wrote:
Hi thomas + list,
working with py, you will also have to define the function of the Python script to be called, for example
[py permute printList]
ah-ha!
Therefore, you could define another function
def printAll(v): printList(list(str(v)))
and then (with [py permute printAll]), try to send it numbers or symbols.
Since I'm only just learning Python, I'll go away and try that, and tell you what happened...
Also, your script function doesn't return any values to be printed by the pd print objects but it will rather output the permuted values to the console.
Erm, could you please point out how to get the permuted values back to pd and not the console?
I realise this may be a python (as opposed to pd) question. Sorry if it's OT.
Thanks for your help so far...
Cheers, dc
www.ariada.uea.ac.uk/~dcasal --)+