IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Python: List Join?
I can't seem to figure out how to collapse a list of strings into a single string with a selectable seperator. I've got a list of strings like:
   strList = ["ABC", "DEF", "GHI"]

That I'd like to join into a single string of the form:
   s = "ABC|DEF|GHI"

Purpose is for use in regexp - something like:
   myMatch = re.Match("(" + "ABC|DEF|GHI" + ")")


New Re: Python: List Join?
"|".join(strlist)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Thanks!
Didn't think of doing it backwards - with the join as a function of the seperator. :-)
New Well, there's also:
string.join(strlist, "|")

All the above does is call arg2.join(arg1), though.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     Python: List Join? - (ChrisR) - (3)
         Re: Python: List Join? - (admin) - (2)
             Thanks! - (ChrisR) - (1)
                 Well, there's also: - (admin)

Ha Ha - just kidding. We're all Lumberjacks and We're OK!
161 ms