[Tutor] Windows - Linux based open() file handle mode

Bill Campbell bill at celestial.net
Tue Nov 20 00:30:01 CET 2007


On Mon, Nov 19, 2007, Srinivas Iyyer wrote:
>Dear group, 
>
>I want to parse an file generated for windows.
>My code works beautifully when I try to parse the same
>file generated in Linux. 
>
>I uses the following options with no success:
>
>blast_out = open('C:\human\prb_blast.out','r')
>
>blast_out = open('C:\human\prb_blast.out','rU')
>
>blast_out = open('C:\human\prb_blast.out','U')
>
>Are there any other ways to solve this problem. 

Try blast_out = open('C:/human/prb_blast.out', 'U') instead of
the $DEITY/Awful DOSish backwacks.

If you're really enamoured of backslashes, add an r before the
single quotes to get what you want.

blast_out = open(r'C:\human\prb_blast.out','U')

Bill
--
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

There is nothing as stupid as an educated man if you get him off the
thing he was educated in.
    Will Rogers


More information about the Tutor mailing list