[PD][ot] py: converting tuple to list
Frank Barknecht
fbar at footils.org
Mon Apr 3 00:48:06 CEST 2006
Hallo,
patco hat gesagt: // patco wrote:
> This returns this error:
>
> largs.append(args[i].replace(' ', '_'))
> AttributeError: 'Symbol' object has no attribute 'replace'
Your args-tuple is coming in through a pyext inlet then. It is not
made up of Python strings then, but of "Symbol"-objects, which are
specific to pyext and they represent the Pd symbol atom in Python. You
can convert them to a string using the str() builtin. (They get
automatically converted in some other uses.
This again can be done very fast using list comprehension:
args_as_string = [str(x) for x in args]
and you can replace spaces with underscores in this step as well:
args_as_string = [str(x).replace(" ","_") for x in args]
Ciao
--
Frank Barknecht _ ______footils.org_ __goto10.org__
More information about the Pd-list
mailing list