Newbie question: how to join a list of elements of user-defined types?
Max M
maxm at mxm.dk
Tue Apr 30 03:59:33 EDT 2002
Cliff Wells wrote:
> On 29 Apr 2002 18:54:12 -0700
> Fortepianissimo wrote:
>>Basically I want to have a subclass of list, like
>>
>>class MyList (list):
>> ...
>>
>>then I want to
>>
>>l=MyList()
>>... do stuff to fill l
>>s=" ".join(l)
>
>
> s = " ".join([str(i) for i in l])
Oh the joy and fun of optimizing code snippets, map() is really nice in
this case:
s = " ".join(map(str,l))
regards Max M
More information about the Python-list
mailing list