Re: equivalent of perl $/

Siebren van der Zee (siebren@vdzee.xs4all.nl)
Wed, 18 Jan 95 20:35 MET

In article <9501161704.AA26014=guido@zeus.cwi.nl> Guido writes:
>> Does python have an equivalent of perl's $/ variable?
>> to be able to read data without \n being special...
>
>Gee, there's no end to the amount of $<magic> that Perl provides
>that's actually useful :-)
>
> [Six lines of code deleted, including an empty one]

You should learn how to sell Python to Perlites, Guido. How about:

records = string.splitfields(open('^!/@\+$').read(), '\0')

This has two advantages:
1) It is less verbose.
2) The file is closed right after splitfields returns.

Also, the filename is more appealing to Perl-programmers.
(Sorry, couldn't resist :-)

Siebren van der Zee, siebren@xs4all.nl
(BTW, does someone know how to emulate $[?, I mean, `$[', erh.. you know...)