[Tutor] list.replace -- string.swap

Alan Gauld alan.gauld at btinternet.com
Tue Mar 17 21:46:06 CET 2009


"spir" <denis.spir at free.fr> wrote 

> Is there a list.replace builtin I cannot find? Or a workaround?

myList[x] = newValue

Or is that too obvious?

> Also: How would perform string.swap(s1, s2) in the following cases:
> 
> * There is no secure 'temp' char, meaning that
> s.replace(s1,temp).replace(s2,s1).replace(temp,s2)
>  will fail because any char can be part of s.
> 
> * Either s1 or s2 can be more than a single char.

Sorry you lost me there. No idea what you mean.

Alan G.



More information about the Tutor mailing list