Re: how to prepend string to a string?



flamesrock wrote:
Thanks for all the responses :)

You're right, Kent. That does exactly what I need it to.

Anyways.. if there isn't a prepend function, I'm going to request it
from the devs. Would be cool to see that in future versions of python.

Since strings cannot be modified in-place (they are "immutable"), the concept of prepend for a string is meaningless (and so is append). Instead, you simply build a new string from other bits, and it's entirely up to you which comes first and which comes second (thus providing implementations equivalent to prepend or append, as you need).


-Peter
.



Relevant Pages

  • Re: Using CreateDirectory problems
    ... "To extend this limit to 32,767 wide characters, call the Unicode version of the function ... looks to me like you've got the wrong string prepended and you need to be sure your ... "finecats" wrote in message ...
    (microsoft.public.win32.programmer.kernel)
  • Perl 6.x , please offer PREPEND as well as APPEND
    ... The asymetric PREPEND and APPEND should be addressed in 6.x: ... # prepend a string - YUK, ugly, ... encounter this syntax. ...
    (comp.lang.perl.misc)
  • Re: prepend operator?
    ... So, with that in mind, what is wrong with: ... "Is there an operator where I can prepend a string to a string, ... Why not unshift it on an array, then join the array with ''? ...
    (comp.lang.php)
  • Re: [PATCH 1/4] Net device error logging, revised
    ... > wouldn't need space for the potentially large resulting string, ... > enough room for the expanded format string. ... prepend args to a va_list. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: prepend operator?
    ... Paul Lautman wrote: ... So, with that in mind, what is wrong with: ... "Is there an operator where I can prepend a string to a string, ...
    (comp.lang.php)