
Hello, I have a question/suggestion about ''.join in Python 1.6. Suppose I have this list: l = ["This", "is", "a", "test"] Currently, I would join it this way into a tab-delimeted string: s = string.join(l, '\t') In 1.6, I should do it this way: '\t'.join(s) I think it would be better to have that method on the *list*: s.join('\t') That's more clear, isn't it? regards, Gerrit. -- Please correct any bad English you encounter in my email message! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK-----

"GH" == Gerrit Holl <gerrit.holl@pobox.com> writes:
GH> I think it would be better to have that method on the *list*: GH> s.join('\t') GH> That's more clear, isn't it? Perhaps, but you want join to work on any sequence don't you? By making it a method on string objects, you sort of get that for free (as opposed to putting it on lists, sequences, and requiring all class authors to add it as well). -Barry

Fredrik Lundh wrote on 948314616:
I understand. Thanks for your answers. regards, Gerrit. -- Please correct any bad English you encounter in my email message! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK-----

"GH" == Gerrit Holl <gerrit.holl@pobox.com> writes:
GH> I think it would be better to have that method on the *list*: GH> s.join('\t') GH> That's more clear, isn't it? Perhaps, but you want join to work on any sequence don't you? By making it a method on string objects, you sort of get that for free (as opposed to putting it on lists, sequences, and requiring all class authors to add it as well). -Barry

Fredrik Lundh wrote on 948314616:
I understand. Thanks for your answers. regards, Gerrit. -- Please correct any bad English you encounter in my email message! -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK-----
participants (4)
-
Barry A. Warsaw
-
David Ascher
-
Fredrik Lundh
-
Gerrit Holl