how to prepend string to a string?
Peter Hansen
peter at engcorp.com
Tue May 31 14:34:47 EDT 2005
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
More information about the Python-list
mailing list