Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > list.join()... re.join()...? Do they exist? (newbie questions...)

Reply
Thread Tools

list.join()... re.join()...? Do they exist? (newbie questions...)

 
 
googleboy
Guest
Posts: n/a
 
      10-01-2005
Hi.

In some google posts I searched suggested that there was a list.join()
thing that I assume works like string.join [which I notice is now
deprecated in favour of S.join()]

It seems that I have been misled.

I start with a text file that I split up to run some formatting over
the various sections with re.split. I want to join it back together
again with a | delimeter and write it out to a new file. I looked for
a re.join, but it seems that doesn't exist. I looked for a list.join
after reading the aforementioned posts, but it doesn't seem to exist
either.

To get it to work I did this:


List[0] = list0
List[1] = list1
List[2] = list2
List[3] = list3
cat_list = list0 + '|' + flatblurb + '|' + flatcontents + '|' + flates
+ '\n'
file.write(concat_list)


But it seems to me that there is probably something more pythonic than
having to go about it in such a laborious fashion....

Would someone be so kind as to fill me in?

TIA!

googleboy

 
Reply With Quote
 
 
 
 
Benji York
Guest
Posts: n/a
 
      10-01-2005
googleboy wrote:
> To get it to work I did this:
>
>
> List[0] = list0
> List[1] = list1
> List[2] = list2
> List[3] = list3
> cat_list = list0 + '|' + flatblurb + '|' + flatcontents + '|' + flates
> + '\n'
> file.write(concat_list)
>
> But it seems to me that there is probably something more pythonic than
> having to go about it in such a laborious fashion....


Indeed.

cat_list = '|'.join(List)
--
Benji York


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MCSE exam # 70-216. They they show you the score?? Jack Black Microsoft Certification 1 12-09-2004 11:54 PM
Temporaries - when do they begin, when do they end? Asfand Yar Qazi C++ 4 11-12-2004 11:58 PM
When they're gone, they could be gone for good... Richard DVD Video 10 06-02-2004 07:13 AM
Is "They Shoot Horses, Don't They?" getting a re-release? Maverick DVD Video 1 10-25-2003 02:17 AM
they turn, they power, they make nice pics Keith and Jenn Z. Digital Photography 0 09-21-2003 04:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57