Hallo, Thomas Grill hat gesagt: // Thomas Grill wrote:
[ symbol ABC ( -> 2nd inlet [ py .str @py 1 ] .... use internal str function and pass on Python object -> 2nd inlet [ pym lower ] .... apply lower method to Python object -> 1st inlet [ print STRING ]
the weakness at the moment is that all PD symbols have to be explicitly converted into string objects, which is not very conventient (especially with symbols in lists). I'll add an attribute, so that this happens automatically, in order to enable easy usage of [ py string.replace ] etc.
Ah, that's cool, pym makes my little script superfluous, which is good.
The automatic conversion could be great. But I wonder, if it could be made to "do the right thing" with floats as well? The pycall.py script I posted just converts everything in the args-list to strings. This has the nasty side effect, that floats or ints are converted as well. For example the "maxsplit" count of string.split() then cannot be used, because the 3 in "split X---Y---Z --- 3" would be converted to a string and Python rightfully complains:
Traceback (most recent call last): File "pycall.py", line 27, in _anything_1 result = getattr(self.mod, func)(*args) File "/usr/lib/python2.3/string.py", line 121, in split return s.split(sep, maxsplit) TypeError: an integer is required
As sometimes strings like "3" are needed as well I don't think there is a really easy solution to automatic conversion, though.
Ciao