[PD][ot] py: converting tuple to list
patco
megalegoland at yahoo.fr
Sun Apr 2 23:19:08 CEST 2006
Okay, the problem has been resolved with using netsend instead of OSC
:D
patco
--- david golightly <davigoli at gmail.com> a écrit :
Hi,
> (moving to off-topic)
Why does it move to off-topic? the problem comes from OSCx
and could be resolved with tcl scripting as well.
> Since tuples are static after creation & can't be changed but only
> reassigned, what you have to do is iterate over the items in the tuple
> to create a new list:
>
> largs = []
> for i in range(len(args)):
> largs.append(args[i].replace(' ', '_'))
>
> return largs
This returns this error:
largs.append(args[i].replace(' ', '_'))
AttributeError: 'Symbol' object has no attribute 'replace'
> I don't understand why you're trying to use reduce(). This method is
> designed to call a function recursively over a set of items or over a
> range, so that each subsequent iteration is called with the result of
> the previous iteration.
ah, yes I didn't delete 'reduce' that comes from many other tests, I've guessed
that this fonction changes nothing in this context.
> Hopefully this is closer to what you're looking for.
>
> -david
Unfortunately, I couldn't figure it out, but thanks lot for attention,
> On 4/2/06, patco <megalegoland at yahoo.fr> wrote:
> > Hello,
> >
> > May be you could be in some help with a script I am trying to do
> > for replacing spaces in a string.
> >
> > I've tried this:
> >
> > def space2_(*args):
> > """replaces space with _"""
> > return reduce(args.replace(' ','_'), args)
> >
> > and the console is returning this error:
> >
> > AttributeError: 'tuple' object has no attribute 'replace'
> >
> > With a very limited knowledge of python, I am having pain for finding
> > how to transform (*args) into [*args] or anything that would allow
> > the fonction 'replace' to work.
> >
> > I need this script for fixing a problem with OSCx,
> > which doesn't allow spaces in sent messages.
> >
> > Thank in advance for any coment.
> >
> > Patco.
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger. Appelez le monde entier à partir de 0,012 /minute !
Téléchargez sur http://fr.messenger.yahoo.com
More information about the Pd-list
mailing list