Custom string joining

Claudiu Popa cpopa at bitdefender.com
Sat May 7 08:31:33 EDT 2011


Hello Python-list,

I  have  an object which defines some methods. I want to join a list or
an iterable of those objects like this:

new_string = "|".join(iterable_of_custom_objects)

What   is   the   __magic__  function that needs to be implemented for
this case to work?  I  though  that  __str__  is sufficient but it doesn't seems to
work. Thanks in advance.

PC

  






More information about the Python-list mailing list