Record seperator

2011-08-26 Thread greymaus

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


Re: Record seperator

2011-08-27 Thread greymaus
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. :))


-- 
maus
 .
  .
...   NO CARRIER
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Record seperator

2011-08-28 Thread greymaus
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 intervals
>>>
>>> open("file.txt").read().split("\n\n")
>>>
>> 
>> 
>> Ta!.. bit awkard. :))
>
> Er, is that meant to be a pun? "Awk[w]ard", as in awk-ward?

Yup, mispelled it and realized th error :)
>
> In any case, no, the Python line might be a handful of characters longer
> than the AWK equivalent, but it isn't awkward. It is logical and easy to
> understand. It's embarrassingly easy to describe what it does:
>
> open("file.txt")   # opens the file
>  .read()   # reads the contents of the file
>  .split("\n\n")# splits the text on double-newlines.
>
> The only tricky part is knowing that \n means newline, but anyone familiar
> with C, Perl, AWK etc. should know that.
>
> The Python code might be "long" (but only by the standards of AWK, which can
> be painfully concise), but it is simple, obvious and readable. A few extra
> characters is the price you pay for making your language readable. At the
> cost of a few extra key presses, you get something that you will be able to
> understand in 10 years time.
>
> AWK is a specialist text processing language. Python is a general scripting
> and programming language. They have different values: AWK values short,
> concise code, Python is willing to pay a little more in source code.
>
>

RS, and its Perl equivelent, which I forget, mean that you can read in
full multiline records. 

(I am coming into Python via Perl from AWK, and trying to get a grip
on the language and its idions)

Thanks to All

Oh, Awk is far more than a text processing language, may be old (like me!)
but useful (ditto)



-- 
maus
 .
  .
...   NO CARRIER
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-15 Thread Greymaus
Mike Meyer wrote:
> You clearly weren't paying attention to what the rest
> of the microcomputer industry was doing while Gates was selling IBM
> non-existent software. While IBM was introducing 16-bit processors and
> DOS was doing a flat file system, Tandy was selliig systems - for a
> fraction of the price of any MS-DOS based system - that were
> multitasking, multiuser, had an optional windowing system that came
> with a complete (for the time) office suite. Of course, that was while
> Tandy still thought they could sell computers by selling better
> computers than you could get running MS software. 


Was that the Color Computer III running OS9 Level II for an operating 
system, that you're talking about?  Motorola 6809 processor?  HELLUVA 
little computer!  OS9 was a bit quirky, though, even for a UNIX clone.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-16 Thread Greymaus
Tim Hammerquist wrote:

> 
> I loved my little CoCo!  I had the original CoCo, upgraded with
> the 5 1/4" floppy drive, and later upgraded the whole system to
> CoCo 3 with OS9.
> 
I put the piggyback RAM board in, which gave me, I think, 1 Meg of RAM. 
I also found that the whole system ran faster and better (especially 
under OS9) with two floppy drives.

Programmed that puppy in OS9BASIC and 6809 Assembler...Much preferred 
the Assembler.  A lot less confusing than Microsoft's assembler!  But I 
had to shift over to PCs when I figured out that Tandy wasn't supporting 
the CoCo system. They took the  40-connector extension boards out of 
their inventory and that killed the market right there.  Another raid 
from Microsoft?

-- 
http://mail.python.org/mailman/listinfo/python-list