On 2011-08-27, Steven D'Aprano wrote:
> greymaus wrote:
>
>> On 2011-08-26, D'Arcy J.M. Cain wrote:
>>> On 26 Aug 2011 18:39:07 GMT
>>> greymaus wrote:
Is there an equivelent for the AWK RS in Python?
as in RS='\n\n'
will seperate a file at two blank line interva
http://stromberg.dnsalias.org/svn/bufsock/trunk does it.
$ cat double-file
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
root:x:0:0:root:/roo
On 8/27/2011 5:07 PM, Roy Smith wrote:
In article,
Terry Reedy wrote:
On 8/27/2011 1:45 PM, Roy Smith wrote:
In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
open("file.txt") # opens the file
.read() # reads the contents of the fi
In article ,
Terry Reedy wrote:
> On 8/27/2011 1:45 PM, Roy Smith wrote:
> > In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
> > Steven D'Aprano wrote:
> >
> >> open("file.txt") # opens the file
> >> .read() # reads the contents of the file
> >> .split("\n\n")
On Sun, Aug 28, 2011 at 6:03 AM, Terry Reedy wrote:
> yield para # or ''.join(para), as desired
>
Or possibly '\n'.join(para) if you want to keep the line breaks inside
paragraphs.
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On 8/27/2011 1:45 PM, Roy Smith wrote:
In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
open("file.txt") # opens the file
.read() # reads the contents of the file
.split("\n\n")# splits the text on double-newlines.
The biggest prob
On Aug 27, 10:45 am, Roy Smith wrote:
> In article <4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
> > open("file.txt") # opens the file
> > .read() # reads the contents of the file
> > .split("\n\n") # splits the text on double-newlines.
>
> Th
In article <4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> open("file.txt") # opens the file
> .read() # reads the contents of the file
> .split("\n\n")# splits the text on double-newlines.
The biggest problem with this code is that read() slurp
greymaus wrote:
> On 2011-08-26, D'Arcy J.M. Cain wrote:
>> On 26 Aug 2011 18:39:07 GMT
>> greymaus wrote:
>>>
>>> Is there an equivelent for the AWK RS in Python?
>>>
>>>
>>> as in RS='\n\n'
>>> will seperate a file at two blank line intervals
>>
>> open("file.txt").read().split("\n\n")
>>
>
On 2011-08-26, D'Arcy J.M. Cain wrote:
> On 26 Aug 2011 18:39:07 GMT
> greymaus wrote:
>>
>> Is there an equivelent for the AWK RS in Python?
>>
>>
>> as in RS='\n\n'
>> will seperate a file at two blank line intervals
>
> open("file.txt").read().split("\n\n")
>
Ta!.. bit awkard. :))
-
On 26 Aug 2011 18:39:07 GMT
greymaus wrote:
>
> Is there an equivelent for the AWK RS in Python?
>
>
> as in RS='\n\n'
> will seperate a file at two blank line intervals
open("file.txt").read().split("\n\n")
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy
11 matches
Mail list logo