string goes away

alex23 wuwei23 at gmail.com
Thu Mar 31 22:32:23 EST 2005


Hey Andreas,

> I loved to use
>  >>> string.join(list_of_str, sep)
> instead of
>  >>> sep.join(list_of_str)
>
> I think the former is much more telling what is happening than the
> latter. However, I will get used to it.

I find that binding a name to the separator makes it more readable
(YMMV):

 >>> list_of_str = ['a','b','c']
 >>> comma = ','
 >>> comma.join(list_of_str)
 'a,b,c'

> But what about this:
>  >>> upper_list = map(string.upper, list_of_str)

 >>> upper_list = [s.upper() for s in list_of_str]
 >>> upper_list
 ['A', 'B', 'C']

Hope this helps.

-alex23




More information about the Python-list mailing list