[Tutor] when string,join won't work
Sean 'Shaleh' Perry
Wed, 03 Jan 2001 10:17:33 -0800 (PST)
On 04-Jan-2001 Moshe Zadka wrote:
> On Wed, 03 Jan 2001 09:04:07 -0800 (PST), "Sean 'Shaleh' Perry"
> <firstname.lastname@example.org> wrote:
>> string.join assumes that the sequence is all strings. What do i do if this
>> not the case. A friend is trying to make db requests and print the returned
>> data. Not every field is a string, so join won't work. Suggestions?
> Make them strings:
> string.join(map(str, sequence))
> Read about ``map'' and ``str'' at your friendly neighbourhood library
> reference guide. (http://www.python.org/doc/)
yeah, I was just hoping there was a better way.
one of the reason to use a scripting language is to get away from:
foo = 'hello';
kind of code. Python requiring me to know that the sequence is 100% strings is
kind of silly in my book.