Yo, I've finally got the good code to put into a pyext script:
def space2_(*args):
"""replaces space with _"""
args_as_string = [str(x).replace(" ","_") for x in args]
return "_".join(args_as_string)
patco.
--- Frank Barknecht fbar@footils.org a écrit :
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]
___________________________________________________________________________ Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international. Téléchargez sur http://fr.messenger.yahoo.com