Record seperator

Dan Stromberg drsalists at gmail.com
Sat Aug 27 21:19:05 EDT 2011


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:/root:/bin/bash
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
benchbox-dstromberg:~/src/home-svn/bufsock/trunk i686-pc-linux-gnu 8830 -
above cmd done 2011 Sat Aug 27 06:19 PM

$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bufsock
>>> file_ = open('double-file', 'rb')
>>> bs = bufsock.bufsock(file_)
>>> bs.readto('oo')
'daemon:x:1:1:daemon:/usr/sbin:/bin/sh\nbin:x:2:2:bin:/bin:/bin/sh\nsys:x:3:3:sys:/dev:/bin/sh\nsync:x:4:65534:sync:/bin:/bin/sync\ngames:x:5:60:games:/usr/games:/bin/sh\nman:x:6:12:man:/var/cache/man:/bin/sh\nroo'
>>> bs.close()
>>>

Don't let the name fool you - it's not just for sockets anymore.

On Fri, Aug 26, 2011 at 11:39 AM, greymaus <greymausg at mail.com> 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
>
>
> --
> maus
>  .
>  .
> ...   NO CARRIER
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110827/8ade63a8/attachment-0001.html>


More information about the Python-list mailing list