Message293232
I think you are misunderstanding how join works.
join is useful when you have a list of strings, and you want to combine them together, possibly specifying a separator. The syntax is separator.join(list_of_strings), for example:
>>> '-'.join(['foo', 'bar', 'baz'])
'foo-bar-baz'
What you are doing is: new_item = new_item.join((item + ';'))
Here new_item is the separator, and (item + ';') is a string (a sequence of characters), so the separator is added between each character of the string:
>>> '-'.join('foobarbaz')
'f-o-o-b-a-r-b-a-z'
new_item will grow bigger and bigger, and since you keep adding it between each character of the item, Python will soon run out of memory:
>>> 'newitem'.join('foobarbaz')
'fnewitemonewitemonewitembnewitemanewitemrnewitembnewitemanewitemz'
You probably want to add the items to a new list, and after the for loop you just need to do '; '.join(new_list_of_items), or, if you want a ; at the end, you can add (item + ';') to the list and then use ' '.join(new_list_of_items).
I also suggest you to use the interactive interpreter to experiment with join. |
|
Date |
User |
Action |
Args |
2017-05-08 11:11:16 | ezio.melotti | set | recipients:
+ ezio.melotti, ronaldoussoren, ned.deily, 方文添 |
2017-05-08 11:11:16 | ezio.melotti | set | messageid: <1494241876.81.0.726776378561.issue30305@psf.upfronthosting.co.za> |
2017-05-08 11:11:16 | ezio.melotti | link | issue30305 messages |
2017-05-08 11:11:16 | ezio.melotti | create | |
|