Python List Joining

I’ve seen lists joined with a delimiter like this before:

strDelimiter = “\n”

But it seems silly to allocate memory just for the delimiter … not a big deal from a resource perspective, and probably using the delimiter variable is more comprehensible in the future … but I’ve always wondered if you couldn’t just use a static string with the join method. Turns out you can —

msgContent.attach(MIMEText(“\n”.join(listOfStuff), ‘plain’))


Leave a Reply

Your email address will not be published. Required fields are marked *