[Tutor] when string,join won't work
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Wed, 3 Jan 2001 18:12:41 -0800 (PST)
> > 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:
>
> string foo;
>
> foo = 'hello';
>
> kind of code. Python requiring me to know that the sequence is 100%
> strings is kind of silly in my book.
True, but it's not so bad if you write a function that does the string
conversion implicitely:
###
def myStrJoin(L):
return string.join(map(str, L))
###
is a one shot thing, so it's not too bad. If something doesn't work, make
it work. *grin*