This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Prepending Text
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: flamesrock, georg.brandl, rhettinger
Priority: normal Keywords:

Created on 2005-05-31 17:59 by flamesrock, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg54553 - (view) Author: Aaron Elbaz (flamesrock) Date: 2005-05-31 17:59
Perhaps this has already been considered, but I have an
idea that would make neat addition to python:

Appending a string to another string can be done with
+= or .join(), but currently, there is no elegant way
to prepend to a string.

How about something like-
string.prepend(list.pop(0)

?
msg54554 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-05-31 18:48
Logged In: YES 
user_id=1188172

-0.
What's wrong with
>>> string = something + string

Also, the above conveys the notion that this is an expensive
operation (when done multiple times, e.g. in a loop) better
than a str method.
msg54555 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-06-03 00:45
Logged In: YES 
user_id=80475

All string concatenation in Python creates a new string and
leaves the original untouched.  So, there are no append
operations.  Likewise, the can be no prepend operations. 
Instead, there are only a+b operations whose result can be
assigned to 'a'  to give the effect of an append, to 'b' to
give the effect of a prepend, and to 'c' to create a new
variable leaving the inputs untouched.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42035
2005-05-31 17:59:12flamesrockcreate