On 16May2015 10:35, bruceg113...@gmail.com <bruceg113...@gmail.com> wrote:
On Saturday, May 16, 2015 at 12:59:19 PM UTC-4, Chris Angelico wrote:
On Sun, May 17, 2015 at 2:22 AM,  <bruceg113...@gmail.com> wrote:
> # Original Approach
> # -----------------
> ss = ss.split("\n")
> ss1 = ""
> for sdata in ss:
>     ss1 = ss1 + (sdata[OFFSET:] + "\n")
>
> # Chris's Approach
> # ----------------
> lines = ss.split("\n")
> new_text = "\n".join(line[8:] for line in lines)
[...]

Your approach more than meets my requirements.
Data is formatted correctly and performance is simply amazing.
OFFSET and \n are small details.

The only comment I'd make at this point is to consider if you really need a single string at the end. Keeping it as a list of lines may be more flexible. (It will consume more memory.) If you're doing more stuff with the string as lines then you'd need to re-split it, and so forth.

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to