Newbie question: how to join a list of elements of user-defined types?

Fredrik Lundh fredrik at pythonware.com
Tue Apr 30 10:27:52 EDT 2002


Benjamin Han wrote:

> This surely looks nicer. I'm just wondering how far Python has fared in terms
> of this concept of OO? This example seems to show a very different character
> of OO in Python, in that __str__ is not automatically called, which seems
> rather counter-intuitive.

join expects a homogenous sequence of string objects.

if you have something else, it's up to you to make it match
the expectations.  in this case, map(str, object) is probably
the best way to do that.

> How much is an effort in converting Python into C++?

none of it, I hope ;-)

to write pythonic python, think templates (interfaces), not
subclasses.

</F>





More information about the Python-list mailing list